@realsee/five-webgpu 1.0.0-alpha.6 → 1.0.0-alpha.7
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/ai_guides/features/five.md +70 -1
- package/ai_guides/features/material.md +35 -8
- package/ai_guides/features/mode.md +23 -6
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/index.AdaptiveLuminancePass.html +1 -1
- package/docs/classes/index.BoundingMesh.html +1 -1
- package/docs/classes/index.Camera.html +1 -1
- package/docs/classes/index.EyeDomeLightingPass.html +1 -1
- package/docs/classes/index.Five.html +60 -59
- package/docs/classes/index.FivePass.html +1 -1
- package/docs/classes/index.FlowingFireworks3DPass.html +1 -1
- package/docs/classes/index.FlowingLight2DPass.html +1 -1
- package/docs/classes/index.FlowingLight3DPass.html +2 -2
- package/docs/classes/index.GaussianBlurPass.html +1 -1
- package/docs/classes/index.InternalWebGPURenderer.html +8 -5
- package/docs/classes/index.Model.html +1 -1
- package/docs/classes/index.ModelScene.html +1 -1
- package/docs/classes/index.NetworkSubscribe.html +1 -1
- package/docs/classes/index.PBMCustomNode.html +8 -8
- package/docs/classes/index.PBMGaussianSplattingNodeMaterial.html +2 -2
- package/docs/classes/index.PBMGaussianSplattingObject.html +1 -1
- package/docs/classes/index.PBMGaussianSplattingRenderMesh.html +1 -1
- package/docs/classes/index.PBMGroup.html +1 -1
- package/docs/classes/index.PBMMesh.html +1 -1
- package/docs/classes/index.PBMMeshBasicMaterial.html +7 -6
- package/docs/classes/index.PBMMeshBasicNodeMaterial.html +9 -8
- package/docs/classes/index.PBMMeshPanoOnlyMaterial.html +7 -6
- package/docs/classes/index.PBMMeshPanoOnlyNodeMaterial.html +7 -6
- package/docs/classes/index.PBMMeshPhongMaterial.html +7 -6
- package/docs/classes/index.PBMMeshPhongNodeMaterial.html +9 -8
- package/docs/classes/index.PBMMeshPhysicalMaterial.html +7 -6
- package/docs/classes/index.PBMMeshPhysicalNodeMaterial.html +9 -8
- package/docs/classes/index.PBMPanoFilter.html +8 -8
- package/docs/classes/index.PBMPointCloud.html +6 -7
- package/docs/classes/index.PBMPointCloudMaterial.html +83 -0
- package/docs/classes/index.PBMSkinnedMesh.html +1 -1
- package/docs/classes/index.PBMUpdateable.html +1 -1
- package/docs/classes/index.PanoCircleMesh.html +1 -1
- package/docs/classes/index.PanoCircleMeshCustom.html +1 -1
- package/docs/classes/index.PanoCircleMeshSolid.html +1 -1
- package/docs/classes/index.Parameter.html +57 -56
- package/docs/classes/index.Scene.html +1 -1
- package/docs/classes/index.Subscribe.html +1 -1
- package/docs/classes/index.Tile3D.html +1 -1
- package/docs/classes/index.TileNode.html +1 -1
- package/docs/classes/index.TrajectoryNode.html +1 -1
- package/docs/classes/index.WorkResolvedObserver.html +1 -1
- package/docs/classes/index.XRButton.html +3 -0
- package/docs/documents/features_five.html +45 -3
- package/docs/documents/features_material.html +20 -9
- package/docs/documents/features_mode.html +27 -2
- package/docs/functions/index.customNodesCacheKey.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/interfaces/index.AddableObject.html +1 -1
- package/docs/interfaces/index.AjaxOptions.html +1 -1
- package/docs/interfaces/index.BaseEvent.html +1 -1
- package/docs/interfaces/index.Clock.html +1 -1
- package/docs/interfaces/index.DeviceProfile.html +8 -0
- package/docs/interfaces/index.EventCallback.html +3 -3
- package/docs/interfaces/index.FiveInitArgs.html +40 -25
- package/docs/interfaces/index.GestureEvent.html +1 -1
- package/docs/interfaces/index.IPBMMaterial.html +6 -5
- package/docs/interfaces/index.ImageOptions.html +1 -1
- package/docs/interfaces/index.IntersectEvent.html +1 -1
- package/docs/interfaces/index.IntersectMesh.html +1 -1
- package/docs/interfaces/index.IntersectMeshInterface.html +1 -1
- package/docs/interfaces/index.Intersection.html +1 -1
- package/docs/interfaces/index.LooseWorkWithExtrinsics.html +1 -1
- package/docs/interfaces/index.ModeChangeEvent.html +2 -2
- package/docs/interfaces/index.ModelControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.ModelEvent.html +2 -2
- package/docs/interfaces/index.ModelSceneEvent.html +2 -2
- package/docs/interfaces/index.ModelTileEvent.html +2 -2
- package/docs/interfaces/index.MovePanoOptions.html +1 -1
- package/docs/interfaces/index.NetworkAbortError.html +1 -1
- package/docs/interfaces/index.NetworkFirbiddenError.html +1 -1
- package/docs/interfaces/index.NetworkOptions.html +1 -1
- package/docs/interfaces/index.NetworkProxyError.html +1 -1
- package/docs/interfaces/index.NetworkResourceEvent.html +2 -2
- package/docs/interfaces/index.NetworkResponseError.html +1 -1
- package/docs/interfaces/index.NetworkTimeoutError.html +1 -1
- package/docs/interfaces/index.ObjectEvent.html +2 -2
- package/docs/interfaces/index.PBMClipperParameter.html +2 -2
- package/docs/interfaces/index.PBMCustomNodeContext.html +30 -30
- package/docs/interfaces/index.PBMCustomNodeOptions.html +4 -4
- package/docs/interfaces/index.PBMCustomNodePanoContext.html +6 -6
- package/docs/interfaces/index.PBMCustomNodeSlots.html +6 -6
- package/docs/interfaces/index.PBMGaussianSplattingNodeMaterialOptions.html +4 -0
- package/docs/interfaces/index.PBMPanoDepth.html +5 -5
- package/docs/interfaces/index.PBMPanoFilterValue.html +2 -2
- package/docs/interfaces/index.PBMPanoGainmap.html +3 -3
- package/docs/interfaces/index.PBMPanoPicture.html +8 -8
- package/docs/interfaces/index.PBMRefinedScreen.html +2 -2
- package/docs/interfaces/index.PanoCircleMeshInterface.html +1 -1
- package/docs/interfaces/index.PanoEvent.html +1 -1
- package/docs/interfaces/index.PanoPrepareEvent.html +15 -0
- package/docs/interfaces/index.PanoTextureEvent.html +1 -1
- package/docs/interfaces/index.PanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.PanoramaLikeControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.ParameterMaterialValue.html +42 -41
- package/docs/interfaces/index.ParameterTilesetValue.html +15 -15
- package/docs/interfaces/index.ParameterValue.html +56 -55
- package/docs/interfaces/index.Pose.html +1 -1
- package/docs/interfaces/index.RenderEvent.html +2 -2
- package/docs/interfaces/index.ResolvedParameterValue.html +56 -55
- package/docs/interfaces/index.State.html +1 -1
- package/docs/interfaces/index.StateEvent.html +1 -1
- package/docs/interfaces/index.TextureOptions.html +1 -1
- package/docs/interfaces/index.TopviewControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.VRPanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.ViewLayer.html +1 -1
- package/docs/interfaces/index.WorkCubeHdrGainmapImage.html +1 -1
- package/docs/interfaces/index.WorkCubeImage.html +1 -1
- package/docs/interfaces/index.WorkImage.html +1 -1
- package/docs/interfaces/index.WorkObserver.html +1 -1
- package/docs/interfaces/index.WorkTile.html +1 -1
- package/docs/interfaces/index.WorksEvent.html +2 -2
- package/docs/interfaces/index.XRControllerEvent.html +2 -2
- package/docs/interfaces/index.XRGestureEvent.html +2 -2
- package/docs/interfaces/index.XRPanoramaControllerCustomInitArgs.html +52 -0
- package/docs/interfaces/index.XRSessionEvent.html +2 -2
- package/docs/modules/index.html +1 -1
- package/docs/types/index.ControllerCustomInitTypes.html +3 -2
- package/docs/types/index.ControllerEventTypes.html +3 -3
- package/docs/types/index.DeviceProfileOverride.html +5 -0
- package/docs/types/index.FlowingLightLineInput.html +11 -0
- package/docs/types/index.Mode.html +6 -4
- package/docs/types/index.OutputTextureDataType.html +1 -1
- package/docs/types/index.PBMCustomNodeTargetType.html +1 -1
- package/docs/types/index.ParseOptions.html +1 -1
- package/docs/types/index.XRMachineType.html +7 -0
- package/docs/variables/index.PBMVertexMarkFlag.html +4 -0
- package/docs/variables/index.controllersDefaultInitArgs.html +1 -1
- package/five/application/controllers.d.ts +4 -0
- package/five/application/five.d.ts +3 -1
- package/five/application/fiveInitArgs.d.ts +19 -1
- package/five/application/mode.d.ts +7 -2
- package/five/controllers/xrPanorama.d.ts +506 -0
- package/five/core/internalWebGPURenderer.d.ts +7 -1
- package/five/core/webglAsyncReadFix.d.ts +25 -0
- package/five/index.d.ts +4 -1
- package/five/index.js +29 -29
- package/five/index.mjs +5201 -3668
- package/five/model/index.d.ts +3 -2
- package/five/model/materials/pbmMaterial.d.ts +13 -1
- package/five/model/materials/pbmMeshMaterial.d.ts +0 -9
- package/five/model/materials/pbmPointCloudNodeMaterial.d.ts +1 -1
- package/five/model/objects/pbmPointCloud.d.ts +0 -1
- package/five/model/objects/pbmPointCloudObject.d.ts +1 -1
- package/five/model/parameter.d.ts +5 -4
- package/five/renderer/index.d.ts +1 -1
- package/five/renderer/postprocessing/index.d.ts +1 -1
- package/five/utils/event.d.ts +9 -2
- package/five/webxr/XRControllerModelFactory.d.ts +55 -0
- package/five/webxr/buttonStateMachine.d.ts +31 -0
- package/five/webxr/deviceProfile.d.ts +70 -0
- package/five/webxr/inputSourceTracker.d.ts +59 -0
- package/five/webxr/referenceSpace.d.ts +60 -0
- package/five/webxr/renderTargetBridge.d.ts +45 -0
- package/five/webxr/xrButton.d.ts +4 -0
- package/five/webxr/xrManager.d.ts +174 -0
- package/gltf-loader/index.js +3 -3
- package/gltf-loader/index.mjs +3 -3
- package/line/circle_png.d.ts +1 -0
- package/line/index.d.ts +49 -0
- package/line/index.js +255 -0
- package/line/index.mjs +340 -0
- package/package.json +25 -5
- package/plugins/FloorplanPlugin/index.d.ts +1 -0
- package/plugins/FloorplanPlugin/typings/floorplanJson.d.ts +167 -0
- package/plugins/FloorplanPlugin/typings/index.d.ts +1 -0
- package/plugins/FloorplanPlugin/utils/formatFloorplanJson.d.ts +20 -0
- package/plugins/FloorplanPlugin/utils/polylabel.d.ts +8 -0
- package/plugins/index.js +361 -6
- package/plugins/index.mjs +25707 -363
- package/plugins/thirdParty/doctorstrange-model.d.ts +92 -0
- package/react/index.js +2 -2
- package/react/index.mjs +2 -2
- package/sticker/geometry.d.ts +3 -0
- package/sticker/index.d.ts +68 -0
- package/sticker/index.js +255 -0
- package/sticker/index.mjs +358 -0
- package/umd/five-gltf-loader.js +3 -3
- package/umd/five-line.js +322 -0
- package/umd/five-plugins.js +370 -15
- package/umd/five-react.js +2 -2
- package/umd/five-sticker.js +255 -0
- package/umd/five-vfx.js +323 -0
- package/umd/five.js +68 -68
- package/vfx/airflow/airflow.d.ts +18 -0
- package/vfx/common/simplex-noise.d.ts +2 -0
- package/vfx/frame/frame.d.ts +27 -0
- package/vfx/index.d.ts +7 -0
- package/vfx/index.js +255 -0
- package/vfx/index.mjs +738 -0
- package/vfx/particle/instance.d.ts +36 -0
- package/vfx/particle/particle.d.ts +119 -0
- package/vfx/particle/utils.d.ts +11 -0
- package/vfx/particle-gpu/particle.d.ts +75 -0
- package/vfx/particle-gpu/utils.d.ts +11 -0
- package/vfx/spotLight/spotLight.d.ts +15 -0
- package/work-downloader/components/model-3d-tile.d.ts +2 -0
- package/work-downloader/components/model.d.ts +3 -0
- package/work-downloader/components/observer.d.ts +9 -0
- package/work-downloader/download.d.ts +16 -0
- package/work-downloader/index.d.ts +2 -0
- package/work-downloader/index.js +255 -0
- package/work-downloader/index.mjs +595 -0
- package/work-downloader/type.d.ts +28 -0
- package/work-downloader/utils/download-to-file.d.ts +1 -0
- package/work-downloader/utils/image-processing.d.ts +7 -0
- package/work-downloader/utils/join-url.d.ts +2 -0
- package/work-downloader/utils/log.d.ts +1 -0
- package/work-downloader/utils/relative-url.d.ts +1 -0
package/five/model/index.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export { PBMGaussianSplattingObject, type SplatData, } from "./objects/pbmGaussi
|
|
|
4
4
|
export { PBMGaussianSplattingObject as PBMGSObject, } from "./objects/pbmGaussianSplattingObject";
|
|
5
5
|
export { PBMPointCloud, type PointCloudData, } from "./objects/pbmPointCloud";
|
|
6
6
|
export { PBMGaussianSplattingRenderMesh, } from "./objects/pbmGaussianSplattingRenderMesh";
|
|
7
|
-
export { PBMGaussianSplattingNodeMaterial, } from "./materials/pbmGaussianSplattingNodeMaterial";
|
|
8
|
-
export {
|
|
7
|
+
export { PBMGaussianSplattingNodeMaterial, type PBMGaussianSplattingNodeMaterialOptions, } from "./materials/pbmGaussianSplattingNodeMaterial";
|
|
8
|
+
export { PBMPointCloudMaterial, } from "./materials/pbmPointCloudMaterial";
|
|
9
|
+
export { PBMUpdateable, PBMPanoFilter, PBMCustomNode, PBMVertexMarkFlag, customNodesCacheKey, type IPBMMaterial, type PBMPanoFilterValue, type PBMAlphaMode, type PBMClipperParameter, type PBMColorStyle, type PBMFloorStyle, type PBMRoofStyle, type PBMPanoPicture, type PBMPanoGainmap, type PBMPanoDepth, type PBMPointBack, type PBMPointCloudShaderType, type PBMPointShape, type PBMPointSize, type PBMRefinedScreen, type PBMTransition, type PBMCustomNodeSlots, type PBMCustomNodeTargetType, type PBMCustomNodeOptions, type PBMCustomNodeContext, type PBMCustomNodePanoContext, } from "./materials/pbmMaterial";
|
|
9
10
|
export { type PBMMeshMaterial, PBMMeshBasicMaterial, PBMMeshPhongMaterial, PBMMeshPhysicalMaterial, PBMMeshPanoOnlyMaterial } from './materials/pbmMeshMaterial';
|
|
10
11
|
export { registerPBMMaterials, } from './materials/pbmMaterialRegister';
|
|
11
12
|
export { PBMMeshBasicNodeMaterial, } from './materials/nodes/pbmMeshBasicNodeMaterial';
|
|
@@ -17,6 +17,17 @@ export type PBMColorStyle = 'RGB' | 'ALTITUDE' | 'CONSTANT';
|
|
|
17
17
|
export type PBMPointShape = 'SQUARE' | 'CIRCLE';
|
|
18
18
|
export type PBMPointSize = 'FIXED' | 'ATTENUATION';
|
|
19
19
|
export type PBMPointBack = 'VISIBLE' | 'HIDDEN' | 'DARK';
|
|
20
|
+
/**
|
|
21
|
+
* 顶点标注档位(按位掩码)。
|
|
22
|
+
* 每一类标注对应一位,可按位独立启用;新增档位时在此追加一位即可。
|
|
23
|
+
*/
|
|
24
|
+
export declare const PBMVertexMarkFlag: {
|
|
25
|
+
readonly none: 0;
|
|
26
|
+
readonly roof: 2;
|
|
27
|
+
readonly hidden: 4;
|
|
28
|
+
/** 全开,默认包含未来新增的所有标注档位 */
|
|
29
|
+
readonly all: 255;
|
|
30
|
+
};
|
|
20
31
|
export declare class PBMUpdateable extends Subscribe<{
|
|
21
32
|
"update": () => void;
|
|
22
33
|
}> {
|
|
@@ -401,7 +412,8 @@ export interface IPBMMaterial {
|
|
|
401
412
|
pointScale: number;
|
|
402
413
|
pointMinPixel: number;
|
|
403
414
|
pointMaxPixel: number;
|
|
404
|
-
|
|
415
|
+
useVertexMarkRoof: boolean;
|
|
416
|
+
useVertexMarkHidden: boolean;
|
|
405
417
|
colorAlpha: number;
|
|
406
418
|
alphaMode: string;
|
|
407
419
|
modelAlpha: number;
|
|
@@ -46,12 +46,3 @@ export type PBMMeshMaterial = PBMMeshBasicMaterial | PBMMeshPhongMaterial | PBMM
|
|
|
46
46
|
export declare function createPBMMeshMaterial(shaderType?: PBMMeshShaderType | {
|
|
47
47
|
shaderType?: PBMMeshShaderType;
|
|
48
48
|
}): PBMMeshMaterial;
|
|
49
|
-
export interface PBMPointCloudMaterial extends THREE.Material, IPBMMaterial {
|
|
50
|
-
}
|
|
51
|
-
export declare class PBMPointCloudMaterial extends THREE.Material implements IPBMMaterial {
|
|
52
|
-
readonly isPBMMaterial: true;
|
|
53
|
-
readonly shaderType = "standard";
|
|
54
|
-
constructor();
|
|
55
|
-
copy(source: PBMPointCloudMaterial): this;
|
|
56
|
-
}
|
|
57
|
-
export declare function createPBMPointCloudMaterial(): PBMPointCloudMaterial;
|
|
@@ -16,7 +16,7 @@ export declare class PBMPointCloudNodeMaterial extends THREE.NodeMaterial {
|
|
|
16
16
|
pointBack: PBMPointBack;
|
|
17
17
|
colorStyle: PBMColorStyle;
|
|
18
18
|
floorStyle: PBMFloorStyle;
|
|
19
|
-
vertexMarks: boolean;
|
|
19
|
+
vertexMarks: boolean | number;
|
|
20
20
|
pointScale: number;
|
|
21
21
|
pointMinPixel: number;
|
|
22
22
|
pointMaxPixel: number;
|
|
@@ -60,7 +60,6 @@ export declare class PBMPointCloud extends THREE.Mesh<THREE.InstancedBufferGeome
|
|
|
60
60
|
outlineGain: number;
|
|
61
61
|
distanceGain: number;
|
|
62
62
|
useAddBlend: boolean;
|
|
63
|
-
vertexMarks: boolean;
|
|
64
63
|
clippers: readonly PBMClipperParameter[];
|
|
65
64
|
readonly modelBoundingMin: THREE.Vector3;
|
|
66
65
|
readonly modelBoundingMax: THREE.Vector3;
|
|
@@ -42,7 +42,7 @@ export declare class PBMPointCloudObject extends THREE.Object3D {
|
|
|
42
42
|
outlineGain: number;
|
|
43
43
|
distanceGain: number;
|
|
44
44
|
useAddBlend: boolean;
|
|
45
|
-
vertexMarks: boolean;
|
|
45
|
+
vertexMarks: boolean | number;
|
|
46
46
|
clippers: readonly PBMClipperParameter[];
|
|
47
47
|
readonly modelBoundingMin: THREE.Vector3;
|
|
48
48
|
readonly modelBoundingMax: THREE.Vector3;
|
|
@@ -4,11 +4,12 @@ import type { TileRequestOrder } from './tile3d/types';
|
|
|
4
4
|
import type { Camera } from '../core/camera';
|
|
5
5
|
export interface ParameterMaterialValue {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* 开启后,模型顶点上会预置 `_feature_id_rsmask`
|
|
9
|
-
* _feature_id_rsmask=1
|
|
7
|
+
* 是否生效标注(按位掩码 PBMVertexMarkFlag)
|
|
8
|
+
* 开启后,模型顶点上会预置 `_feature_id_rsmask` 标记,可按位独立控制开盖(roof)与隐藏(hidden)。
|
|
9
|
+
* _feature_id_rsmask=1 对应 roof,在俯视等特定视角下引擎会自动隐藏被标记的顶点对应的 Mesh,从而实现“开盖”效果,让室内布局观测更加清晰、观感更好。
|
|
10
|
+
* 兼容旧的 boolean:true=全开(all),false=全关(none)。
|
|
10
11
|
*/
|
|
11
|
-
vertexMarks: boolean;
|
|
12
|
+
vertexMarks: boolean | number;
|
|
12
13
|
/** 起始点 */
|
|
13
14
|
pano0: PBMPanoPicture | null;
|
|
14
15
|
/** 结束点 */
|
package/five/renderer/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { EffectComposer, FivePass, type Pass, AdaptiveLuminancePass, EyeDomeLightingPass, FlowingLight2DPass, type FlowingLight2DPassLine, FlowingLight3DPass, type FlowingLight3DPassLine, GaussianBlurPass, FlowingFireworks3DPass, type FlowingFireworks3DPassLine, } from './postprocessing';
|
|
1
|
+
export { EffectComposer, FivePass, type Pass, AdaptiveLuminancePass, EyeDomeLightingPass, FlowingLight2DPass, type FlowingLight2DPassLine, FlowingLight3DPass, type FlowingLight3DPassLine, type FlowingLightLineInput, GaussianBlurPass, FlowingFireworks3DPass, type FlowingFireworks3DPassLine, } from './postprocessing';
|
|
2
2
|
export { FullScreenQuad } from './tools/full-screen-quad';
|
|
3
3
|
export { FiveRenderer } from './five-renderer';
|
|
@@ -4,5 +4,5 @@ export { AdaptiveLuminancePass } from './passes/adaptive-luminance-pass';
|
|
|
4
4
|
export { EyeDomeLightingPass } from './passes/eye-dome-lighting-pass';
|
|
5
5
|
export { GaussianBlurPass } from './passes/gaussian-blur-pass';
|
|
6
6
|
export { FlowingLight2DPass, type FlowingLight2DPassLine } from './passes/flowing-light-2d-pass';
|
|
7
|
-
export { FlowingLight3DPass, type FlowingLight3DPassLine } from './passes/flowing-light-3d-pass';
|
|
7
|
+
export { FlowingLight3DPass, type FlowingLight3DPassLine, type FlowingLightLineInput } from './passes/flowing-light-3d-pass';
|
|
8
8
|
export { FlowingFireworks3DPass, type FlowingFireworks3DPassLine } from './passes/flowing-fireworks-3d-pass';
|
package/five/utils/event.d.ts
CHANGED
|
@@ -87,9 +87,16 @@ export interface GestureEvent extends StateEvent {
|
|
|
87
87
|
overallVelocityX: number;
|
|
88
88
|
overallVelocityY: number;
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* XR 设备类型。
|
|
92
|
+
* - `Pico`:字节 Pico 系列
|
|
93
|
+
* - `Oculus`:Meta Quest / Oculus 系列
|
|
94
|
+
* - `VP`:Apple Vision Pro
|
|
95
|
+
*/
|
|
96
|
+
export type XRMachineType = 'Pico' | 'Oculus' | 'VP';
|
|
90
97
|
export interface XRSessionEvent extends BaseEvent {
|
|
91
98
|
session: XRSession | null;
|
|
92
|
-
machineType:
|
|
99
|
+
machineType: XRMachineType;
|
|
93
100
|
}
|
|
94
101
|
export interface XRControllerEvent extends BaseEvent {
|
|
95
102
|
left: {
|
|
@@ -126,7 +133,7 @@ export interface XRControllerEvent extends BaseEvent {
|
|
|
126
133
|
export interface XRGestureEvent extends BaseEvent {
|
|
127
134
|
session: XRSession | null;
|
|
128
135
|
buttons: 'A' | 'B' | 'X' | 'Y' | 'RightTrigger' | 'RightPinch' | 'LeftTrigger' | 'LeftPinch' | 'LeftAxesLeft' | 'LeftAxesRight' | 'LeftAxesUp' | 'LeftAxesDown' | 'RightAxesLeft' | 'RightAxesRight' | 'RightAxesUp' | 'RightAxesDown';
|
|
129
|
-
machineType:
|
|
136
|
+
machineType: XRMachineType;
|
|
130
137
|
isFirst: boolean;
|
|
131
138
|
isFinal: boolean;
|
|
132
139
|
controllers: {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Object3D } from 'three/webgpu';
|
|
2
|
+
import * as THREE from 'three/webgpu';
|
|
3
|
+
/**
|
|
4
|
+
* @description Builds a motion controller with components and visual responses based on the
|
|
5
|
+
* supplied profile description. Data is polled from the xrInputSource's gamepad.
|
|
6
|
+
* @author Nell Waliczek / https://github.com/NellWaliczek
|
|
7
|
+
*/
|
|
8
|
+
declare class MotionController {
|
|
9
|
+
/**
|
|
10
|
+
* @param {Object} xrInputSource - The XRInputSource to build the MotionController around
|
|
11
|
+
* @param {Object} profile - The best matched profile description for the supplied xrInputSource
|
|
12
|
+
* @param {Object} assetUrl
|
|
13
|
+
*/
|
|
14
|
+
xrInputSource: XRInputSource;
|
|
15
|
+
assetUrl: string;
|
|
16
|
+
id: any;
|
|
17
|
+
layoutDescription: any;
|
|
18
|
+
components: any;
|
|
19
|
+
constructor(xrInputSource: XRInputSource, profile: any, assetUrl: string);
|
|
20
|
+
get gripSpace(): XRSpace | undefined;
|
|
21
|
+
get targetRaySpace(): XRSpace;
|
|
22
|
+
/**
|
|
23
|
+
* @description Returns a subset of component data for simplified debugging
|
|
24
|
+
*/
|
|
25
|
+
get data(): any[];
|
|
26
|
+
/**
|
|
27
|
+
* @description Poll for updated data based on current gamepad state
|
|
28
|
+
*/
|
|
29
|
+
updateFromGamepad(): void;
|
|
30
|
+
}
|
|
31
|
+
declare class XRControllerModel extends Object3D {
|
|
32
|
+
motionController: MotionController | null;
|
|
33
|
+
envMap: THREE.Texture | null;
|
|
34
|
+
constructor();
|
|
35
|
+
setEnvironmentMap(envMap: THREE.Texture): this;
|
|
36
|
+
/**
|
|
37
|
+
* Polls data from the XRInputSource and updates the model's components to match
|
|
38
|
+
* the real world data
|
|
39
|
+
*/
|
|
40
|
+
updateMatrixWorld(force: boolean): void;
|
|
41
|
+
}
|
|
42
|
+
declare class XRControllerModelFactory {
|
|
43
|
+
path: string;
|
|
44
|
+
_assetCache: any;
|
|
45
|
+
gltfLoader: {
|
|
46
|
+
load: (url: string, callback: (result: {
|
|
47
|
+
scene: THREE.Object3D;
|
|
48
|
+
}) => void) => any;
|
|
49
|
+
} | null;
|
|
50
|
+
constructor(gltfLoader?: {
|
|
51
|
+
load: () => any;
|
|
52
|
+
} | null);
|
|
53
|
+
createControllerModel(controller: any): XRControllerModel;
|
|
54
|
+
}
|
|
55
|
+
export { XRControllerModelFactory };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ButtonName = 'A' | 'B' | 'X' | 'Y' | 'LeftTrigger' | 'RightTrigger' | 'LeftPinch' | 'RightPinch';
|
|
2
|
+
export type ButtonEventType = 'buttonDown' | 'press' | 'buttonUp' | 'tap';
|
|
3
|
+
export interface ButtonEvent {
|
|
4
|
+
type: ButtonEventType;
|
|
5
|
+
name: ButtonName;
|
|
6
|
+
source: XRInputSource;
|
|
7
|
+
time: number;
|
|
8
|
+
duration: number;
|
|
9
|
+
}
|
|
10
|
+
/** 区分 tap 与 press 的阈值(毫秒):时长 < 300 为 tap,>= 300(含恰好 300)为 press */
|
|
11
|
+
export declare const TAP_PRESS_THRESHOLD_MS = 300;
|
|
12
|
+
export declare class ButtonStateMachine {
|
|
13
|
+
/** 以输入源对象为外层键;使用 Map 以便 removeSource / reset 遍历 */
|
|
14
|
+
private readonly states;
|
|
15
|
+
/**
|
|
16
|
+
* 采样一个按键,返回按派发顺序排列的事件(可能为空)。
|
|
17
|
+
* 严格遵循设计 4.5 的状态转移表。
|
|
18
|
+
*/
|
|
19
|
+
sample(source: XRInputSource, name: ButtonName, pressed: boolean, time: number): ButtonEvent[];
|
|
20
|
+
/**
|
|
21
|
+
* 输入源被移除:该输入源每个按下中的键只派发 buttonUp(不派发 tap / press),
|
|
22
|
+
* 并清除该输入源的全部状态。
|
|
23
|
+
*/
|
|
24
|
+
removeSource(source: XRInputSource, time: number): ButtonEvent[];
|
|
25
|
+
/**
|
|
26
|
+
* 会话结束:全部按下中的键只派发 buttonUp(不派发 tap / press),并清空全部状态。
|
|
27
|
+
*/
|
|
28
|
+
reset(time: number): ButtonEvent[];
|
|
29
|
+
/** 删除单个键的状态;输入源下无按下键时一并移除外层条目 */
|
|
30
|
+
private deleteState;
|
|
31
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export type DeviceType = 'Pico' | 'Oculus' | 'VP' | 'Default';
|
|
2
|
+
/** 对外事件(`machineType`)中出现的设备类型,不含 `Default`。 */
|
|
3
|
+
export type PublicMachineType = 'Pico' | 'Oculus' | 'VP';
|
|
4
|
+
/** 手柄按键 / 轴映射与模型选择(需求 11.11)。 */
|
|
5
|
+
export interface DeviceProfile {
|
|
6
|
+
/** `gamepad.buttons` 下标,`null` 表示不映射(VP) */
|
|
7
|
+
buttons: {
|
|
8
|
+
trigger: number | null;
|
|
9
|
+
grip: number | null;
|
|
10
|
+
primary: number | null;
|
|
11
|
+
secondary: number | null;
|
|
12
|
+
pinch: number | null;
|
|
13
|
+
};
|
|
14
|
+
/** `gamepad.axes` 下标,`null` 表示不映射 */
|
|
15
|
+
axes: {
|
|
16
|
+
x: number | null;
|
|
17
|
+
y: number | null;
|
|
18
|
+
};
|
|
19
|
+
/** `'auto'`:由 `XRControllerModelFactory` 按 profiles 加载;`'none'`:不加载模型 */
|
|
20
|
+
model: 'auto' | 'none';
|
|
21
|
+
}
|
|
22
|
+
/** 调用方对 {@link DeviceProfile} 的按字段覆盖(需求 11.4)。 */
|
|
23
|
+
export type DeviceProfileOverride = {
|
|
24
|
+
buttons?: Partial<DeviceProfile['buttons']>;
|
|
25
|
+
axes?: Partial<DeviceProfile['axes']>;
|
|
26
|
+
model?: DeviceProfile['model'];
|
|
27
|
+
};
|
|
28
|
+
/** 非法覆盖字段的告警回调,参数为字段名,例如 `'buttons.trigger'`、`'axes.x'`、`'model'`。 */
|
|
29
|
+
export type DeviceProfileWarn = (field: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* 四种设备类型的默认 Device_Profile(深冻结,只读)。
|
|
32
|
+
*
|
|
33
|
+
* 需要可修改的副本时使用 {@link resolveProfile}。
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEFAULT_PROFILES: Readonly<Record<DeviceType, Readonly<DeviceProfile>>>;
|
|
36
|
+
/**
|
|
37
|
+
* 通过 UA 判定设备类型(需求 11.3)。
|
|
38
|
+
*
|
|
39
|
+
* 判定顺序,命中第一个即返回:
|
|
40
|
+
* 1. UA 含 `PICO` 或 `Pico`(区分大小写)→ `Pico`(Pico 4 的 UA 同时含 `OculusBrowser`,必须先判 Pico)
|
|
41
|
+
* 2. UA 含 `Macintosh` 且 `maxTouchPoints === 5` → `VP`
|
|
42
|
+
* 3. UA 含 `Oculus` → `Oculus`
|
|
43
|
+
* 4. 其它 → `Default`
|
|
44
|
+
*
|
|
45
|
+
* 参数缺省时读取 `navigator.userAgent` / `navigator.maxTouchPoints`;读取抛错一律返回 `Default`,永不抛错。
|
|
46
|
+
*
|
|
47
|
+
* @param ua - User-Agent,缺省取 `navigator.userAgent`
|
|
48
|
+
* @param maxTouchPoints - 最大触点数,缺省取 `navigator.maxTouchPoints`
|
|
49
|
+
*/
|
|
50
|
+
export declare function detectDeviceType(ua?: string, maxTouchPoints?: number): DeviceType;
|
|
51
|
+
/**
|
|
52
|
+
* 生成实际生效的 Device_Profile(需求 11.4)。
|
|
53
|
+
*
|
|
54
|
+
* - 先深拷贝 `type` 对应的默认值(未知类型回落 `Default`),不修改 {@link DEFAULT_PROFILES}。
|
|
55
|
+
* - 覆盖字段为合法值(`null` 或 ≥ 0 的整数)才覆盖;非法下标回落默认值并调用 `warn(字段名)`。
|
|
56
|
+
* - `model` 只接受 `'auto'` / `'none'`,非法回落默认值并 `warn('model')`。
|
|
57
|
+
* - 未提供(`undefined`)的字段保留默认值,不告警。
|
|
58
|
+
*
|
|
59
|
+
* @param type - 设备类型
|
|
60
|
+
* @param override - 调用方覆盖
|
|
61
|
+
* @param warn - 非法字段告警回调,参数为字段名(如 `'buttons.trigger'`)
|
|
62
|
+
* @returns 新对象,可自由修改
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveProfile(type: DeviceType, override?: DeviceProfileOverride, warn?: DeviceProfileWarn): DeviceProfile;
|
|
65
|
+
/**
|
|
66
|
+
* 把内部设备类型映射为事件中 `machineType` 的公开取值(需求 13.1)。
|
|
67
|
+
*
|
|
68
|
+
* `Default` 映射为 `'Pico'`,与迁移前“其余归为 Pico”的行为一致;其余原样返回。
|
|
69
|
+
*/
|
|
70
|
+
export declare function toPublicMachineType(device: DeviceType): PublicMachineType;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as THREE from "three/webgpu";
|
|
2
|
+
/**
|
|
3
|
+
* 单个输入源的追踪条目。
|
|
4
|
+
*/
|
|
5
|
+
export interface TrackedInput {
|
|
6
|
+
/** 对应的 XR 输入源(条目的键,与 `session.inputSources` 下标无关) */
|
|
7
|
+
source: XRInputSource;
|
|
8
|
+
/** target ray 节点,位置/朝向直接写世界值(已加 offset) */
|
|
9
|
+
targetRay: THREE.Object3D;
|
|
10
|
+
/** grip 节点,位置/朝向直接写世界值(已加 offset) */
|
|
11
|
+
grip: THREE.Object3D;
|
|
12
|
+
/** 最近一次 target ray 成功更新(pose 非空)时的帧号 */
|
|
13
|
+
rayFrame: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class InputSourceTracker {
|
|
16
|
+
/** 所有手柄节点的父节点;调用方负责把它加入 scene,`clear()` 不会移除它自身 */
|
|
17
|
+
readonly root: THREE.Group<THREE.Object3DEventMap>;
|
|
18
|
+
private readonly _entries;
|
|
19
|
+
/** `fill` 用的临时向量,避免每次调用分配 */
|
|
20
|
+
private readonly _dir;
|
|
21
|
+
/**
|
|
22
|
+
* 为 `inputsourceschange` 中 `added` 的输入源新增追踪条目。
|
|
23
|
+
* 已存在的输入源被忽略(不重建节点)。新节点初始不可见,待首个有效 pose 到来后显示。
|
|
24
|
+
*/
|
|
25
|
+
add(sources: readonly XRInputSource[]): void;
|
|
26
|
+
/**
|
|
27
|
+
* 删除 `inputsourceschange` 中 `removed` 的输入源条目,并把节点从 `root` 移除。
|
|
28
|
+
*
|
|
29
|
+
* @returns 实际被删除的条目(未追踪的输入源不会出现在结果中)
|
|
30
|
+
*/
|
|
31
|
+
remove(sources: readonly XRInputSource[]): TrackedInput[];
|
|
32
|
+
update(frame: XRFrame, ref: XRReferenceSpace, offset: THREE.Vector3, frameNo: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* 隐藏全部节点,保持上一帧的位置与朝向不变(需求 6.10:Head_Pose 为 `null` 时调用)。
|
|
35
|
+
* 不触碰 `rayFrame`,由 `fill` 对 `visible` 的检查保证不会再填充射线。
|
|
36
|
+
*/
|
|
37
|
+
hideAll(): void;
|
|
38
|
+
/**
|
|
39
|
+
* 用指定输入源本帧的 target ray 填充复用的 Raycaster(需求 6.8)。
|
|
40
|
+
*
|
|
41
|
+
* 仅当该输入源有条目、`rayFrame === frameNo` 且 target ray 节点可见时才写入:
|
|
42
|
+
* origin 为节点世界位置,direction 为局部 -Z 经世界旋转后的单位向量。
|
|
43
|
+
* 否则不修改 `raycaster`。
|
|
44
|
+
*
|
|
45
|
+
* @returns 本帧是否已填充
|
|
46
|
+
*/
|
|
47
|
+
fill(source: XRInputSource, raycaster: THREE.Raycaster, frameNo: number): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* 清空全部追踪条目,并把所有节点从 `root` 移除(需求 6.11)。
|
|
50
|
+
* `root` 自身不移除,由调用方管理。
|
|
51
|
+
*/
|
|
52
|
+
clear(): void;
|
|
53
|
+
/** 当前全部追踪条目(键为 `XRInputSource` 对象) */
|
|
54
|
+
entries(): ReadonlyMap<XRInputSource, TrackedInput>;
|
|
55
|
+
/**
|
|
56
|
+
* 把参考空间位姿写入节点:位置加 offset、朝向直接取 pose,并同步世界矩阵。
|
|
57
|
+
*/
|
|
58
|
+
private _applyPose;
|
|
59
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** 单个类型的失败原因:被拒绝 / 超时。 */
|
|
2
|
+
export type ReferenceSpaceFailureReason = 'rejected' | 'timeout';
|
|
3
|
+
/** 一次失败的尝试记录。 */
|
|
4
|
+
export interface ReferenceSpaceFailure {
|
|
5
|
+
type: XRReferenceSpaceType;
|
|
6
|
+
reason: ReferenceSpaceFailureReason;
|
|
7
|
+
}
|
|
8
|
+
/** 解析结果。 */
|
|
9
|
+
export interface ResolvedReferenceSpace {
|
|
10
|
+
/** 实际采用的参考空间对象 */
|
|
11
|
+
space: XRReferenceSpace;
|
|
12
|
+
/** 实际采用的类型 */
|
|
13
|
+
type: XRReferenceSpaceType;
|
|
14
|
+
/** 采用之前失败的类型(按尝试顺序) */
|
|
15
|
+
failures: ReferenceSpaceFailure[];
|
|
16
|
+
}
|
|
17
|
+
/** 解析选项。 */
|
|
18
|
+
export interface ResolveReferenceSpaceOptions {
|
|
19
|
+
/** 单次请求的超时毫秒数,默认 5000 */
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
/** 会话是否已提前结束;每次 await 之后检查,为真则抛出 aborted 错误 */
|
|
22
|
+
isAborted?: () => boolean;
|
|
23
|
+
/** 注入的 setTimeout,便于假计时器;默认使用全局 setTimeout */
|
|
24
|
+
schedule?: (callback: () => void, ms: number) => unknown;
|
|
25
|
+
/** 注入的 clearTimeout,与 schedule 配对;默认使用全局 clearTimeout */
|
|
26
|
+
clear?: (handle: any) => void;
|
|
27
|
+
}
|
|
28
|
+
/** 全部类型失败时抛出的错误:附带按尝试顺序排列的 `attempts`。 */
|
|
29
|
+
export interface ReferenceSpaceExhaustedError extends Error {
|
|
30
|
+
attempts: ReferenceSpaceFailure[];
|
|
31
|
+
}
|
|
32
|
+
/** 会话提前结束时抛出的错误:带 `aborted: true` 标记。 */
|
|
33
|
+
export interface ReferenceSpaceAbortedError extends Error {
|
|
34
|
+
aborted: true;
|
|
35
|
+
}
|
|
36
|
+
/** 单次请求默认超时(毫秒)。 */
|
|
37
|
+
export declare const DEFAULT_REFERENCE_SPACE_TIMEOUT_MS = 5000;
|
|
38
|
+
/** 判断一个错误是否为「会话在参考空间解析前已结束」。 */
|
|
39
|
+
export declare function isReferenceSpaceAbortedError(error: unknown): error is ReferenceSpaceAbortedError;
|
|
40
|
+
/**
|
|
41
|
+
* 构造降级链:`[preferred, 'local', 'viewer']` 去重并保持顺序,且以 'viewer' 收尾。
|
|
42
|
+
*
|
|
43
|
+
* 去重后在第一个 'viewer' 处截断:期望类型为 'viewer' 时链仅含 'viewer',
|
|
44
|
+
* 不会在 viewer 失败后再多请求一次 'local'(需求 10.1)。
|
|
45
|
+
*
|
|
46
|
+
* @param preferred - 期望的参考空间类型
|
|
47
|
+
* @returns 降级链(preferred 为 'local' 时 ['local','viewer'];为 'viewer' 时 ['viewer'];
|
|
48
|
+
* 其它类型 x 时 [x,'local','viewer'])
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildChain(preferred: XRReferenceSpaceType): XRReferenceSpaceType[];
|
|
51
|
+
/**
|
|
52
|
+
* 解析参考空间:按降级链串行请求,采用第一个成功的类型。
|
|
53
|
+
*
|
|
54
|
+
* @param session - 当前 XRSession
|
|
55
|
+
* @param preferred - 期望的参考空间类型
|
|
56
|
+
* @param opts - 超时、中止检查与计时器注入
|
|
57
|
+
* @returns 采用的空间、类型与此前的失败记录
|
|
58
|
+
* @throws 会话提前结束时抛出 `aborted: true` 的错误;全部失败时抛出带 `attempts` 的错误
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveReferenceSpace(session: XRSession, preferred: XRReferenceSpaceType, opts?: ResolveReferenceSpaceOptions): Promise<ResolvedReferenceSpace>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as THREE from "three/webgpu";
|
|
2
|
+
/** 每只眼的渲染信息:viewport 为 XRViewport 语义(左下原点的 x, y, width, height) */
|
|
3
|
+
export interface BridgeEye {
|
|
4
|
+
camera: THREE.PerspectiveCamera;
|
|
5
|
+
viewport: THREE.Vector4;
|
|
6
|
+
}
|
|
7
|
+
export interface RenderTargetBridgeOptions {
|
|
8
|
+
/** 眼图集 MSAA 采样数,默认 0 */
|
|
9
|
+
atlasSamples?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class RenderTargetBridge {
|
|
12
|
+
private readonly renderer;
|
|
13
|
+
private readonly atlasSamples;
|
|
14
|
+
private resources;
|
|
15
|
+
private warnedRevision;
|
|
16
|
+
private _outputBufferType;
|
|
17
|
+
private readonly clearColorScratch;
|
|
18
|
+
private readonly viewportScratch;
|
|
19
|
+
constructor(renderer: THREE.WebGPURenderer, opts?: RenderTargetBridgeOptions);
|
|
20
|
+
/** `init` 时读取的 `renderer.getOutputBufferType()`(未初始化为 `null`),只供诊断(风险 R5)。 */
|
|
21
|
+
get outputBufferType(): number | null;
|
|
22
|
+
/**
|
|
23
|
+
* 检查 three 内部 API 是否存在、四个标志位值是否符合预期(需求 4.6)。
|
|
24
|
+
* 缺失或不符时抛出含全部问题名称与 `THREE.REVISION` 的错误。
|
|
25
|
+
*/
|
|
26
|
+
verify(): void;
|
|
27
|
+
/** 检查 Eye_Camera 与 renderer 的 `coordinateSystem` 一致(design「进入时校验 camera.coordinateSystem」)。 */
|
|
28
|
+
verifyCameras(cameras: ReadonlyArray<THREE.Camera>): void;
|
|
29
|
+
/** 为 layer 创建眼图集、XR 输出目标与解析 quad;重复调用会先释放旧资源。 */
|
|
30
|
+
init(layer: XRWebGLLayer): void;
|
|
31
|
+
/**
|
|
32
|
+
* 一帧:清图集 → 逐眼渲染 → 解析。任何异常在 `finally` 恢复 renderer 状态后原样抛出(需求 4.7)。
|
|
33
|
+
* `eyes[i].viewport` 是 XRViewport 语义(左下原点)。
|
|
34
|
+
*/
|
|
35
|
+
renderFrame(layer: XRWebGLLayer, scene: THREE.Scene, eyes: ReadonlyArray<BridgeEye>): void;
|
|
36
|
+
/** 幂等释放(需求 4.4):目标各 dispose 至多一次,输出目标与 XR framebuffer 复位为 `null`。 */
|
|
37
|
+
dispose(): void;
|
|
38
|
+
/** 尺寸或 baseLayer 变化(或尚未创建)时重建,返回当前可用的资源(需求 4.8)。 */
|
|
39
|
+
private syncResources;
|
|
40
|
+
private build;
|
|
41
|
+
/** 释放当前资源(不动 renderer 状态;状态由 renderFrame 的 finally 与 dispose 负责)。 */
|
|
42
|
+
private releaseResources;
|
|
43
|
+
/** 检测 `EXT_color_buffer_float` / `EXT_color_buffer_half_float`;拿不到 GL 上下文时按不支持处理。 */
|
|
44
|
+
private supportsHalfFloat;
|
|
45
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as THREE from "three/webgpu";
|
|
2
|
+
import { InputSourceTracker } from "./inputSourceTracker";
|
|
3
|
+
import { DeviceType, DeviceProfile, DeviceProfileOverride } from "./deviceProfile";
|
|
4
|
+
export type { DeviceType } from "./deviceProfile";
|
|
5
|
+
export interface XRManagerOptions {
|
|
6
|
+
/** 期望参考空间类型,默认 'local-floor'(需求 10) */
|
|
7
|
+
referenceSpaceType?: XRReferenceSpaceType;
|
|
8
|
+
/** 0..1,XR_Layer 支持 fixedFoveation 时设置(需求 1.13) */
|
|
9
|
+
foveation?: number;
|
|
10
|
+
/** 调用方覆盖 Device_Profile(需求 11.4) */
|
|
11
|
+
deviceProfile?: DeviceProfileOverride;
|
|
12
|
+
/** 首帧超时,默认 5000ms(需求 2.9) */
|
|
13
|
+
firstFrameTimeoutMs?: number;
|
|
14
|
+
/** 眼图集 MSAA 采样数,默认 0,透传给 RenderTargetBridge */
|
|
15
|
+
atlasSamples?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface XRManagerCallbacks {
|
|
18
|
+
onSessionStart(session: XRSession, device: DeviceType): void;
|
|
19
|
+
onSessionEnd(device: DeviceType): void;
|
|
20
|
+
/**
|
|
21
|
+
* 会话结束归还流程中、`inputs.clear()` 之前调用,供控制器重置按键状态(需求 8.9)。
|
|
22
|
+
* 回调抛错不会中断归还。
|
|
23
|
+
*/
|
|
24
|
+
onSessionEnding?(): void;
|
|
25
|
+
/** session 'select' 事件,供 gaze / transient-pointer 走点(需求 9.4) */
|
|
26
|
+
onSelect?(source: XRInputSource): void;
|
|
27
|
+
/** inputsourceschange,供控制器创建 / 移除手柄模型(需求 7.3、7.5) */
|
|
28
|
+
onInputSourcesChange?(added: readonly XRInputSource[], removed: readonly XRInputSource[]): void;
|
|
29
|
+
}
|
|
30
|
+
export interface FrameInfo {
|
|
31
|
+
time: number;
|
|
32
|
+
/** Head_Pose 为 null 或 views 数量不是 1/2 时为 false(需求 3.6) */
|
|
33
|
+
hasPose: boolean;
|
|
34
|
+
/** 仅 hasPose 时有效 */
|
|
35
|
+
headOrientation: THREE.Quaternion;
|
|
36
|
+
/** 各 view 平移均值(需求 6.2),仅 hasPose 时有效 */
|
|
37
|
+
headLocal: THREE.Vector3;
|
|
38
|
+
/** 与 Eye_Camera 对应的 view 列表,保持 Head_Pose.views 顺序;viewport 为 XRViewport 语义(左下原点) */
|
|
39
|
+
views: ReadonlyArray<{
|
|
40
|
+
eye: 0 | 1;
|
|
41
|
+
viewport: THREE.Vector4;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
export declare class XRManager {
|
|
45
|
+
/**
|
|
46
|
+
* 后端是否支持 XR(后端非 WebGPU 即可)。
|
|
47
|
+
* 以实际 backend 为准:`backend.isWebGPUBackend !== true`。
|
|
48
|
+
*/
|
|
49
|
+
static isBackendXRCapable(renderer: THREE.WebGPURenderer): boolean;
|
|
50
|
+
/** 浏览器是否暴露了 WebXR 入口(只检查 `navigator.xr` 是否存在,不发起权限请求)。 */
|
|
51
|
+
static isBrowserXRCapable(): boolean;
|
|
52
|
+
/** 恒为长度 2 的元组,会话内(实际是整个 XRManager 生命周期内)同一对实例(需求 3.1) */
|
|
53
|
+
readonly eyeCameras: readonly [THREE.PerspectiveCamera, THREE.PerspectiveCamera];
|
|
54
|
+
readonly inputs: InputSourceTracker;
|
|
55
|
+
readonly device: DeviceType;
|
|
56
|
+
readonly profile: Readonly<DeviceProfile>;
|
|
57
|
+
get isPresenting(): boolean;
|
|
58
|
+
get session(): XRSession | null;
|
|
59
|
+
get frame(): XRFrame | null;
|
|
60
|
+
/** 实际采用的参考空间类型,未进入或已结束时为 null(需求 10.5) */
|
|
61
|
+
get referenceSpaceType(): XRReferenceSpaceType | null;
|
|
62
|
+
private readonly renderer;
|
|
63
|
+
private readonly options;
|
|
64
|
+
private readonly callbacks;
|
|
65
|
+
private readonly bridge;
|
|
66
|
+
private _isPresenting;
|
|
67
|
+
private _session;
|
|
68
|
+
private _frame;
|
|
69
|
+
private _referenceSpaceType;
|
|
70
|
+
private refSpace;
|
|
71
|
+
private layer;
|
|
72
|
+
/** enter 流程进行中 */
|
|
73
|
+
private entering;
|
|
74
|
+
/** enter 流程已完成且尚未归还 */
|
|
75
|
+
private entered;
|
|
76
|
+
/** 进入期间会话已结束(需求 1.11) */
|
|
77
|
+
private endedDuringEnter;
|
|
78
|
+
private snapshot;
|
|
79
|
+
private readonly listeners;
|
|
80
|
+
private firstFrameArrived;
|
|
81
|
+
private firstFrameWaiter;
|
|
82
|
+
private frameNo;
|
|
83
|
+
private submittedNear;
|
|
84
|
+
private submittedFar;
|
|
85
|
+
private readonly offset;
|
|
86
|
+
private readonly info;
|
|
87
|
+
/** 池化的 view 条目,最多 2 个 */
|
|
88
|
+
private readonly viewPool;
|
|
89
|
+
/** 当前帧有效的 view(`info.views` 指向它) */
|
|
90
|
+
private readonly frameViews;
|
|
91
|
+
private readonly bridgeEyes;
|
|
92
|
+
private readonly tmpViewport;
|
|
93
|
+
private readonly tmpSize;
|
|
94
|
+
constructor(renderer: THREE.WebGPURenderer, options: XRManagerOptions, callbacks: XRManagerCallbacks);
|
|
95
|
+
/**
|
|
96
|
+
* 进入 XR(design 4.1 的 11 个步骤)。
|
|
97
|
+
* 幂等:进入中或已进入时直接返回。失败时回滚到进入前状态并抛出原始错误。
|
|
98
|
+
*/
|
|
99
|
+
enter(session: XRSession): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* 主动退出:已进入时调用一次 `session.end()`,归还由随后的 `end` 事件完成(需求 1.5)。
|
|
102
|
+
* `end()` reject 时在本地完成归还且不外抛(需求 1.12)。未进入时直接返回。
|
|
103
|
+
*/
|
|
104
|
+
exit(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* 析构,幂等。
|
|
107
|
+
* - 进入中:中止进入(enter 会以“会话在进入过程中已结束”reject)并尝试结束会话;
|
|
108
|
+
* - 已进入:同步完成本地归还,再尝试 `session.end()`(其后到达的 end 事件因监听已移除而被忽略);
|
|
109
|
+
* - 未进入:直接返回。
|
|
110
|
+
*/
|
|
111
|
+
dispose(): void;
|
|
112
|
+
/**
|
|
113
|
+
* 每帧第一步(design 4.2):计算 Head_Pose、更新两个 Eye_Camera 与手柄位姿、同步深度范围、统计诊断。
|
|
114
|
+
*
|
|
115
|
+
* 返回的 `FrameInfo` 是内部复用的对象,仅在下一次 `beginFrame` 之前有效。
|
|
116
|
+
* 尚未就绪(参考空间还没解析完,例如 `Five.changeMode` 提前 `setContext(session)` 后到达的帧)时返回 `hasPose = false`,
|
|
117
|
+
* 且不计入首帧、不计入统计。
|
|
118
|
+
*
|
|
119
|
+
* @param station Station_Position(five Camera 位置)
|
|
120
|
+
*/
|
|
121
|
+
beginFrame(frame: XRFrame, time: number, station: THREE.Vector3, near: number, far: number): FrameInfo;
|
|
122
|
+
/**
|
|
123
|
+
* 渲染本帧:清图集一次 → 逐眼 render → 解析 pass。
|
|
124
|
+
* `hasPose` 为假或尚未就绪返回 `false`(本帧被跳过);否则返回 `true`。
|
|
125
|
+
* `renderer.render` 抛错时由 Bridge 恢复状态后原样抛出。
|
|
126
|
+
*/
|
|
127
|
+
renderEyes(scene: THREE.Scene): boolean;
|
|
128
|
+
/** 以 target ray 填充射线,返回本帧是否已填充(需求 6.8) */
|
|
129
|
+
fillRaycaster(source: XRInputSource, raycaster: THREE.Raycaster): boolean;
|
|
130
|
+
private markNoPose;
|
|
131
|
+
/**
|
|
132
|
+
* 建立眼映射并读取各 view 的 viewport,写入 `frameViews`(需求 3.2)。
|
|
133
|
+
* `left` / `none` → 0,`right` → 1;该下标已被前一个 view 占用时取另一只。
|
|
134
|
+
* 任一 view 取不到 viewport 时返回 false,调用方按无姿态处理(此时尚未改动任何 Eye_Camera)。
|
|
135
|
+
*/
|
|
136
|
+
private collectViews;
|
|
137
|
+
/** near/far 与最近一次提交值不同时才更新一次 renderState(需求 1.10) */
|
|
138
|
+
private syncDepthRange;
|
|
139
|
+
private notifyFirstFrame;
|
|
140
|
+
private throwIfEnded;
|
|
141
|
+
private waitFirstFrame;
|
|
142
|
+
/** 把 `session.inputSources` 里尚未追踪的输入源补进来并通知控制器 */
|
|
143
|
+
private syncExistingInputSources;
|
|
144
|
+
private listen;
|
|
145
|
+
private removeListeners;
|
|
146
|
+
/** 稳定的箭头函数字段,保证 add / remove 用同一个引用 */
|
|
147
|
+
private onSessionEndEvent;
|
|
148
|
+
private onInputSourcesChangeEvent;
|
|
149
|
+
private onSelectEvent;
|
|
150
|
+
/** 沿用同一参考空间对象;Station_Position 不变,下一帧 beginFrame 会依据新 Head_Pose 重算 */
|
|
151
|
+
private onReferenceSpaceReset;
|
|
152
|
+
/** 记录渲染器状态(视口、autoClear*、pixelRatio、尺寸)。不主动调用 setPixelRatio / setSize。 */
|
|
153
|
+
private captureRendererState;
|
|
154
|
+
/** 恢复记录点;仅在值不同时才还原(避免无谓的 setPixelRatio / setSize 重置视口) */
|
|
155
|
+
private restoreRendererState;
|
|
156
|
+
/** 仅当 AnimationFrameLoop 的 context 仍是本 session 时才置 null,避免误清别人的 context */
|
|
157
|
+
private releaseFrameSource;
|
|
158
|
+
/** 清空会话相关引用(不含回调) */
|
|
159
|
+
private clearReferences;
|
|
160
|
+
/**
|
|
161
|
+
* 进入失败的回滚(幂等):移除监听、`bridge.dispose`、`setContext(null)`、恢复渲染器状态、清引用。
|
|
162
|
+
* 不调用任何回调;不结束 session(交给调用方决定)。
|
|
163
|
+
*/
|
|
164
|
+
private rollback;
|
|
165
|
+
/**
|
|
166
|
+
* 会话结束归还(`end` 事件 / `exit` 中 `end()` reject / `dispose` 共用),固定顺序(design 4.1):
|
|
167
|
+
* isPresenting=false → onSessionEnding → inputs.clear → bridge.dispose → 移除监听 → setContext(null)
|
|
168
|
+
* → 恢复渲染器状态 → 清引用 → onSessionEnd。
|
|
169
|
+
* `_session` 已为 null 时(重复调用)直接忽略。
|
|
170
|
+
*/
|
|
171
|
+
private teardown;
|
|
172
|
+
/** fire-and-forget 结束会话,吞掉可能的 reject(会话可能已在结束中) */
|
|
173
|
+
private endQuietly;
|
|
174
|
+
}
|