ice3 0.1.0 → 0.2.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/README.md +9 -0
- package/dist/_types/core/scene/ICENode.d.ts +6 -1
- package/dist/_types/renderer/Color.d.ts +2 -0
- package/dist/_types/renderer/FakeRendererBackend.d.ts +1 -1
- package/dist/_types/renderer/InstanceBatch.d.ts +14 -0
- package/dist/_types/renderer/RenderBatch.d.ts +17 -0
- package/dist/_types/renderer/Renderables.d.ts +9 -0
- package/dist/_types/renderer/RendererProfiler.d.ts +19 -0
- package/dist/_types/renderer/RendererSelection.d.ts +12 -0
- package/dist/_types/renderer/WebGL2GeometryBatch.d.ts +2 -9
- package/dist/_types/renderer/WebGL2InstanceBatch.d.ts +3 -14
- package/dist/_types/renderer/WebGL2RenderBatch.d.ts +1 -16
- package/dist/_types/renderer/WebGL2RendererBackend.d.ts +9 -2
- package/dist/_types/renderer/WebGPUBundleCache.d.ts +14 -0
- package/dist/_types/renderer/WebGPUCapabilities.d.ts +23 -0
- package/dist/_types/renderer/WebGPUDrawStorage.d.ts +27 -0
- package/dist/_types/renderer/WebGPUGeometryCache.d.ts +45 -0
- package/dist/_types/renderer/WebGPUInstanceCache.d.ts +24 -0
- package/dist/_types/renderer/WebGPUInstanceStorage.d.ts +39 -0
- package/dist/_types/renderer/WebGPUPicker.d.ts +30 -0
- package/dist/_types/renderer/WebGPUProbe.d.ts +21 -0
- package/dist/_types/renderer/WebGPURenderPipeline.d.ts +22 -0
- package/dist/_types/renderer/WebGPURenderPlan.d.ts +23 -0
- package/dist/_types/renderer/WebGPURendererBackend.d.ts +111 -0
- package/dist/_types/renderer/WebGPUResources.d.ts +9 -0
- package/dist/_types/renderer/WebGPUSelectionMask.d.ts +18 -0
- package/dist/_types/renderer/WebGPUTimestampProfiler.d.ts +16 -0
- package/dist/_types/renderer/WebGPUVisibility.d.ts +27 -0
- package/dist/_types/renderer/index.d.ts +21 -7
- package/dist/_types/renderer/types.d.ts +15 -3
- package/dist/_types/runtime/ICE3.d.ts +14 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3204 -143
- package/dist/index.js.map +4 -4
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -47,7 +47,16 @@ scene.addChild(new ICEMesh({
|
|
|
47
47
|
engine.setScene(scene).setCamera(camera).start();
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
默认使用 WebGL2。WebGPU 是实验性能力,必须显式使用
|
|
51
|
+
`await new ICE3({ renderer: 'webgpu' }).initAsync(host)` 才会启用;`auto` 保留为
|
|
52
|
+
WebGL2 兼容别名。拾取使用 `await engine.pick(point)`。
|
|
53
|
+
|
|
50
54
|
完整文档和相关工具见
|
|
51
55
|
[Engine 文档](https://github.com/ice-3d/ice3-engine/blob/main/README.md)。
|
|
52
56
|
|
|
57
|
+
工业模型接入 Runtime 前,使用配套的
|
|
58
|
+
[ICE3 Toolchain](https://github.com/ice-3d/ice3-toolchain/blob/main/README.md)
|
|
59
|
+
进行离线格式转换、验证、切分、LOD 和 Tileset 发布。功能与格式支持见
|
|
60
|
+
[Toolchain 功能指南](https://github.com/ice-3d/ice3-toolchain/blob/main/docs/guides/capabilities.md)。
|
|
61
|
+
|
|
53
62
|
本项目采用 MIT License。
|
|
@@ -50,13 +50,17 @@ export declare class ICENode extends ICEEventDispatcher {
|
|
|
50
50
|
readonly position: ICEVector3;
|
|
51
51
|
readonly rotation: ICEVector3;
|
|
52
52
|
readonly scale: ICEVector3;
|
|
53
|
-
visible: boolean;
|
|
54
53
|
private _parent;
|
|
55
54
|
private readonly _children;
|
|
56
55
|
private readonly worldMatrix;
|
|
57
56
|
private localMatrixOverride;
|
|
57
|
+
private _visible;
|
|
58
|
+
private _revision;
|
|
58
59
|
constructor(options: ICENodeOptions);
|
|
59
60
|
get typeId(): string;
|
|
61
|
+
get visible(): boolean;
|
|
62
|
+
set visible(value: boolean);
|
|
63
|
+
get revision(): number;
|
|
60
64
|
get parent(): ICENode | null;
|
|
61
65
|
get children(): readonly ICENode[];
|
|
62
66
|
addChild(node: ICENode): this;
|
|
@@ -71,6 +75,7 @@ export declare class ICENode extends ICEEventDispatcher {
|
|
|
71
75
|
toJSON(): ICESerializedNode;
|
|
72
76
|
dispose(): void;
|
|
73
77
|
private getRoot;
|
|
78
|
+
private markSceneChanged;
|
|
74
79
|
private isAncestorOf;
|
|
75
80
|
private localMatrix;
|
|
76
81
|
}
|
|
@@ -19,7 +19,7 @@ export declare class FakeRendererBackend implements ICERendererBackend {
|
|
|
19
19
|
prepareBatchGeometry(): void;
|
|
20
20
|
releaseBatchGeometry(): void;
|
|
21
21
|
render(frame: ICEFrame): void;
|
|
22
|
-
pick(): string | undefined
|
|
22
|
+
pick(): Promise<string | undefined>;
|
|
23
23
|
dispose(): void;
|
|
24
24
|
get disposeCount(): number;
|
|
25
25
|
private assertActive;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ICEBasicMaterial, ICEGeometry } from '../core/index.js';
|
|
2
|
+
import type { ICEGeometryRenderable } from './Renderables.js';
|
|
3
|
+
export interface ICEInstanceBatch {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly geometry: ICEGeometry;
|
|
6
|
+
readonly material: ICEBasicMaterial;
|
|
7
|
+
readonly instanceMatrices: Float32Array;
|
|
8
|
+
readonly semanticIds: readonly string[];
|
|
9
|
+
readonly semanticIndices: Uint32Array;
|
|
10
|
+
readonly meshIds: readonly string[];
|
|
11
|
+
readonly materialKey: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function collectInstanceBatches(renderables: readonly ICEGeometryRenderable[], output?: ICEInstanceBatch[]): readonly ICEInstanceBatch[];
|
|
14
|
+
//# sourceMappingURL=InstanceBatch.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ICEBasicMaterial, ICEGeometry, ICENode, ICEScene } from '../core/index.js';
|
|
2
|
+
export interface ICERenderBatchNode extends ICENode {
|
|
3
|
+
readonly geometry: ICEGeometry;
|
|
4
|
+
readonly material: ICEBasicMaterial;
|
|
5
|
+
readonly semanticIds: readonly string[];
|
|
6
|
+
readonly semanticNodeIds: readonly string[];
|
|
7
|
+
readonly semanticSelectionIds: readonly string[];
|
|
8
|
+
readonly materialKey: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ICERenderBatchDraw {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly batch: ICERenderBatchNode;
|
|
13
|
+
readonly worldMatrix: Float32Array;
|
|
14
|
+
}
|
|
15
|
+
export declare function collectRenderBatches(scene: ICEScene, output?: ICERenderBatchDraw[]): readonly ICERenderBatchDraw[];
|
|
16
|
+
export declare function semanticSelectionId(batch: Pick<ICERenderBatchNode, 'semanticSelectionIds'>, semanticIndex: number): string | undefined;
|
|
17
|
+
//# sourceMappingURL=RenderBatch.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICEMesh, type ICEScene } from '../core/index.js';
|
|
2
|
+
export interface ICEGeometryRenderable {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly mesh: ICEMesh;
|
|
5
|
+
readonly worldMatrix: Float32Array;
|
|
6
|
+
}
|
|
7
|
+
export declare function collectRenderables(scene: ICEScene, output?: ICEGeometryRenderable[]): readonly ICEGeometryRenderable[];
|
|
8
|
+
export declare const selectionIdentity: (mesh: ICEMesh) => string;
|
|
9
|
+
//# sourceMappingURL=Renderables.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ICEFrameStageProfile = Readonly<{
|
|
2
|
+
collectMs: number;
|
|
3
|
+
prepareAndUploadMs: number;
|
|
4
|
+
encodeMs: number;
|
|
5
|
+
submitMs: number;
|
|
6
|
+
}>;
|
|
7
|
+
type Stage = 'collect' | 'prepareAndUpload' | 'encode' | 'submit';
|
|
8
|
+
export declare class RendererProfiler {
|
|
9
|
+
private enabled;
|
|
10
|
+
private cursor;
|
|
11
|
+
private readonly marks;
|
|
12
|
+
enable(value: boolean): void;
|
|
13
|
+
get isEnabled(): boolean;
|
|
14
|
+
begin(): void;
|
|
15
|
+
mark(stage: Stage): void;
|
|
16
|
+
end(): ICEFrameStageProfile | null;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=RendererProfiler.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ICE3RendererPreference, ICE3RendererSelection, ICERendererBackend } from './types.js';
|
|
2
|
+
export type ICERendererFactories = Readonly<{
|
|
3
|
+
createWebGPU: () => Promise<ICERendererBackend>;
|
|
4
|
+
createWebGL2: () => ICERendererBackend;
|
|
5
|
+
}>;
|
|
6
|
+
export type ICERendererBackendSelection = Readonly<{
|
|
7
|
+
backend: ICERendererBackend;
|
|
8
|
+
selection: ICE3RendererSelection;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function selectRendererBackend(preference: ICE3RendererPreference, factories: ICERendererFactories): Promise<ICERendererBackendSelection>;
|
|
11
|
+
export declare function selectDefaultRendererBackend(preference: ICE3RendererPreference): Promise<ICERendererBackendSelection>;
|
|
12
|
+
//# sourceMappingURL=RendererSelection.d.ts.map
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
readonly id: string;
|
|
4
|
-
readonly mesh: ICEMesh;
|
|
5
|
-
readonly worldMatrix: Float32Array;
|
|
6
|
-
}
|
|
7
|
-
export declare function collectRenderables(scene: ICEScene, output?: ICEGeometryRenderable[]): readonly ICEGeometryRenderable[];
|
|
8
|
-
export declare const selectionIdentity: (mesh: ICEMesh) => string;
|
|
9
|
-
export { collectRenderBatches, semanticSelectionId, type ICERenderBatchDraw, type ICERenderBatchNode, } from './WebGL2RenderBatch.js';
|
|
1
|
+
export { collectRenderables, selectionIdentity, type ICEGeometryRenderable, } from './Renderables.js';
|
|
2
|
+
export { collectRenderBatches, semanticSelectionId, type ICERenderBatchDraw, type ICERenderBatchNode, } from './RenderBatch.js';
|
|
10
3
|
//# sourceMappingURL=WebGL2GeometryBatch.d.ts.map
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import type { ICEBasicMaterial, ICEGeometry } from '../core/index.js';
|
|
2
1
|
import { WebGL2GeometryCache } from './WebGL2GeometryCache.js';
|
|
3
|
-
import type {
|
|
4
|
-
export type { ICEGeometryRenderable } from './
|
|
5
|
-
export
|
|
6
|
-
readonly id: string;
|
|
7
|
-
readonly geometry: ICEGeometry;
|
|
8
|
-
readonly material: ICEBasicMaterial;
|
|
9
|
-
readonly instanceMatrices: Float32Array;
|
|
10
|
-
readonly semanticIds: readonly string[];
|
|
11
|
-
readonly semanticIndices: Uint32Array;
|
|
12
|
-
readonly meshIds: readonly string[];
|
|
13
|
-
readonly materialKey: string;
|
|
14
|
-
}
|
|
2
|
+
import type { ICEInstanceBatch } from './InstanceBatch.js';
|
|
3
|
+
export type { ICEGeometryRenderable } from './Renderables.js';
|
|
4
|
+
export { collectInstanceBatches, type ICEInstanceBatch, } from './InstanceBatch.js';
|
|
15
5
|
export interface WebGL2InstanceEntry {
|
|
16
6
|
readonly vertexArray: WebGLVertexArrayObject;
|
|
17
7
|
readonly matrixBuffer: WebGLBuffer;
|
|
@@ -37,5 +27,4 @@ export declare class WebGL2InstanceCache {
|
|
|
37
27
|
get totalBytes(): number;
|
|
38
28
|
private deleteEntry;
|
|
39
29
|
}
|
|
40
|
-
export declare function collectInstanceBatches(renderables: readonly ICEGeometryRenderable[], output?: ICEInstanceBatch[]): readonly ICEInstanceBatch[];
|
|
41
30
|
//# sourceMappingURL=WebGL2InstanceBatch.d.ts.map
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export interface ICERenderBatchNode extends ICENode {
|
|
3
|
-
readonly geometry: ICEGeometry;
|
|
4
|
-
readonly material: ICEBasicMaterial;
|
|
5
|
-
readonly semanticIds: readonly string[];
|
|
6
|
-
readonly semanticNodeIds: readonly string[];
|
|
7
|
-
readonly semanticSelectionIds: readonly string[];
|
|
8
|
-
readonly materialKey: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ICERenderBatchDraw {
|
|
11
|
-
readonly id: string;
|
|
12
|
-
readonly batch: ICERenderBatchNode;
|
|
13
|
-
readonly worldMatrix: Float32Array;
|
|
14
|
-
}
|
|
15
|
-
export declare function collectRenderBatches(scene: ICEScene, output?: ICERenderBatchDraw[]): readonly ICERenderBatchDraw[];
|
|
16
|
-
export declare function semanticSelectionId(batch: Pick<ICERenderBatchNode, 'semanticSelectionIds'>, semanticIndex: number): string | undefined;
|
|
1
|
+
export { collectRenderBatches, semanticSelectionId, type ICERenderBatchDraw, type ICERenderBatchNode, } from './RenderBatch.js';
|
|
17
2
|
//# sourceMappingURL=WebGL2RenderBatch.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ICEGeometry } from '../core/index.js';
|
|
2
|
+
import { type ICEFrameStageProfile } from './RendererProfiler.js';
|
|
2
3
|
import type { ICERendererBackend, ICERendererCapabilities, ICEFrame, ICEScreenPoint, ICEViewport } from './types.js';
|
|
3
|
-
export
|
|
4
|
+
export { colorToRgba } from './Color.js';
|
|
4
5
|
export declare class WebGL2RendererBackend implements ICERendererBackend {
|
|
5
6
|
capabilities: Readonly<ICERendererCapabilities>;
|
|
6
7
|
private canvas;
|
|
@@ -20,6 +21,8 @@ export declare class WebGL2RendererBackend implements ICERendererBackend {
|
|
|
20
21
|
private readonly batchesScratch;
|
|
21
22
|
private readonly instancesScratch;
|
|
22
23
|
private readonly instancedMeshIds;
|
|
24
|
+
private readonly profiler;
|
|
25
|
+
private lastFrameProfile;
|
|
23
26
|
private backgroundRgba;
|
|
24
27
|
private frameStats;
|
|
25
28
|
private readonly handleContextLost;
|
|
@@ -34,7 +37,11 @@ export declare class WebGL2RendererBackend implements ICERendererBackend {
|
|
|
34
37
|
prepareBatchGeometry(geometry: ICEGeometry): void;
|
|
35
38
|
releaseBatchGeometry(geometry: ICEGeometry): void;
|
|
36
39
|
render(frame: ICEFrame): void;
|
|
37
|
-
|
|
40
|
+
enableProfiling(enabled: boolean): void;
|
|
41
|
+
get frameProfile(): ICEFrameStageProfile | null;
|
|
42
|
+
pick(frame: ICEFrame, point: ICEScreenPoint): Promise<string | undefined>;
|
|
43
|
+
capture(): Promise<Blob>;
|
|
44
|
+
finish(): Promise<void>;
|
|
38
45
|
dispose(): void;
|
|
39
46
|
getViewport(): ICEViewport;
|
|
40
47
|
getDevicePixelRatio(): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class WebGPUBundleCache {
|
|
2
|
+
private readonly device;
|
|
3
|
+
private readonly format;
|
|
4
|
+
private key;
|
|
5
|
+
private bundle;
|
|
6
|
+
private recreations;
|
|
7
|
+
constructor(device: GPUDevice, format: GPUTextureFormat);
|
|
8
|
+
get(key: string, record: (encoder: GPURenderBundleEncoder) => void): GPURenderBundle;
|
|
9
|
+
get current(): GPURenderBundle | null;
|
|
10
|
+
get bundleRecreations(): number;
|
|
11
|
+
invalidate(): void;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=WebGPUBundleCache.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type ICEWebGPUAccelerationTier = 'baseline' | 'storage' | 'gpu-driven';
|
|
2
|
+
export declare const WEBGPU_STORAGE_DEFAULT = false;
|
|
3
|
+
export declare const WEBGPU_GPU_DRIVEN_DEFAULT = false;
|
|
4
|
+
export declare const WEBGPU_INSTANCE_VISIBILITY_THRESHOLD = 1024;
|
|
5
|
+
export type ICEWebGPUOptimizationStats = Readonly<{
|
|
6
|
+
tier: ICEWebGPUAccelerationTier;
|
|
7
|
+
selectionMaskActive: boolean;
|
|
8
|
+
bundleActive: boolean;
|
|
9
|
+
storageActive: boolean;
|
|
10
|
+
visibilityActive: boolean;
|
|
11
|
+
instanceUploadBytes: number;
|
|
12
|
+
bundleRecreations: number;
|
|
13
|
+
timestampUnavailableReason?: string;
|
|
14
|
+
}>;
|
|
15
|
+
export type ICEWebGPUAcceleration = Readonly<{
|
|
16
|
+
tier: ICEWebGPUAccelerationTier;
|
|
17
|
+
storage: boolean;
|
|
18
|
+
visibility: boolean;
|
|
19
|
+
maxStorageBufferBindingSize: number;
|
|
20
|
+
minStorageBufferOffsetAlignment: number;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function detectWebGPUAcceleration(device: GPUDevice): ICEWebGPUAcceleration;
|
|
23
|
+
//# sourceMappingURL=WebGPUCapabilities.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type ICEWebGPUDrawUniform = Readonly<{
|
|
2
|
+
matrix: ArrayLike<number>;
|
|
3
|
+
color: readonly [number, number, number, number];
|
|
4
|
+
useVertexColor: boolean;
|
|
5
|
+
useInstancing: boolean;
|
|
6
|
+
semanticHighlight?: number;
|
|
7
|
+
useSemantic?: boolean;
|
|
8
|
+
selectionBase: number;
|
|
9
|
+
useSelectionMask: boolean;
|
|
10
|
+
pageBase?: number;
|
|
11
|
+
useIndirect?: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
export declare class WebGPUDrawStorage {
|
|
14
|
+
private readonly minimumCapacity;
|
|
15
|
+
private uniformBuffer;
|
|
16
|
+
private capacity;
|
|
17
|
+
private generationValue;
|
|
18
|
+
private count;
|
|
19
|
+
constructor(minimumCapacity?: number);
|
|
20
|
+
begin(requiredDraws: number): void;
|
|
21
|
+
append(draw: ICEWebGPUDrawUniform): number;
|
|
22
|
+
get uniformData(): Float32Array;
|
|
23
|
+
get drawCount(): number;
|
|
24
|
+
get generation(): number;
|
|
25
|
+
private ensureCapacity;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=WebGPUDrawStorage.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ICEGeometry } from '../core/index.js';
|
|
2
|
+
export interface WebGPUGeometryEntry {
|
|
3
|
+
readonly vertexBuffer: GPUBuffer;
|
|
4
|
+
readonly triangleIndexBuffer: GPUBuffer;
|
|
5
|
+
readonly edgeIndexBuffer: GPUBuffer | null;
|
|
6
|
+
readonly semanticBuffer: GPUBuffer | null;
|
|
7
|
+
readonly triangleCount: number;
|
|
8
|
+
readonly edgeCount: number;
|
|
9
|
+
readonly indexFormat: GPUIndexFormat;
|
|
10
|
+
readonly vertexCount: number;
|
|
11
|
+
readonly bytes: number;
|
|
12
|
+
lastUsedFrame: number;
|
|
13
|
+
}
|
|
14
|
+
export interface WebGPUGeometryCacheOptions {
|
|
15
|
+
readonly device: GPUDevice;
|
|
16
|
+
readonly inactiveGraceFrames?: number;
|
|
17
|
+
readonly maxBytes?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class WebGPUGeometryCache {
|
|
20
|
+
private readonly device;
|
|
21
|
+
private readonly entries;
|
|
22
|
+
private active;
|
|
23
|
+
private readonly pinned;
|
|
24
|
+
private readonly inactiveGraceFrames;
|
|
25
|
+
private readonly maxBytes;
|
|
26
|
+
private uploads;
|
|
27
|
+
private evictions;
|
|
28
|
+
private frameId;
|
|
29
|
+
private resourceGeneration;
|
|
30
|
+
constructor(options: WebGPUGeometryCacheOptions);
|
|
31
|
+
retain(geometry: ICEGeometry): WebGPUGeometryEntry;
|
|
32
|
+
pin(geometry: ICEGeometry): WebGPUGeometryEntry;
|
|
33
|
+
unpin(geometry: ICEGeometry): void;
|
|
34
|
+
beginFrame(): void;
|
|
35
|
+
endFrame(): void;
|
|
36
|
+
clear(): void;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
get totalBytes(): number;
|
|
39
|
+
get uploadCount(): number;
|
|
40
|
+
get evictionCount(): number;
|
|
41
|
+
get generation(): number;
|
|
42
|
+
private enforceBudget;
|
|
43
|
+
private deleteEntry;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=WebGPUGeometryCache.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ICEInstanceBatch } from './InstanceBatch.js';
|
|
2
|
+
export interface WebGPUInstanceEntry {
|
|
3
|
+
readonly matrixBuffer: GPUBuffer;
|
|
4
|
+
readonly semanticBuffer: GPUBuffer;
|
|
5
|
+
instanceCount: number;
|
|
6
|
+
readonly bytes: number;
|
|
7
|
+
readonly generation: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class WebGPUInstanceCache {
|
|
10
|
+
private readonly device;
|
|
11
|
+
private readonly entries;
|
|
12
|
+
private active;
|
|
13
|
+
private bufferGeneration;
|
|
14
|
+
constructor(device: GPUDevice);
|
|
15
|
+
retain(batch: ICEInstanceBatch): WebGPUInstanceEntry;
|
|
16
|
+
beginFrame(): void;
|
|
17
|
+
endFrame(): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
dispose(): void;
|
|
20
|
+
get totalBytes(): number;
|
|
21
|
+
get generation(): number;
|
|
22
|
+
private deleteEntry;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=WebGPUInstanceCache.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ICEGeometry } from '../core/index.js';
|
|
2
|
+
import type { ICEInstanceBatch } from './InstanceBatch.js';
|
|
3
|
+
export declare const INSTANCE_RECORD_BYTES = 96;
|
|
4
|
+
export type ICEInstanceStoragePagePlan = Readonly<{
|
|
5
|
+
firstInstance: number;
|
|
6
|
+
instanceCount: number;
|
|
7
|
+
}>;
|
|
8
|
+
export type ICEInstanceStoragePage = ICEInstanceStoragePagePlan & {
|
|
9
|
+
readonly buffer: GPUBuffer;
|
|
10
|
+
};
|
|
11
|
+
export type ICEInstanceStorageEntry = Readonly<{
|
|
12
|
+
pages: readonly ICEInstanceStoragePage[];
|
|
13
|
+
generation: number;
|
|
14
|
+
bytes: number;
|
|
15
|
+
}>;
|
|
16
|
+
export type WebGPUInstanceStorageOptions = {
|
|
17
|
+
readonly maxBindingBytes: number;
|
|
18
|
+
readonly minOffsetAlignment: number;
|
|
19
|
+
};
|
|
20
|
+
export declare class WebGPUInstanceStorage {
|
|
21
|
+
private readonly device;
|
|
22
|
+
private readonly entries;
|
|
23
|
+
private active;
|
|
24
|
+
private resourceGeneration;
|
|
25
|
+
private uploadBytes;
|
|
26
|
+
private readonly maxBindingBytes;
|
|
27
|
+
private readonly minOffsetAlignment;
|
|
28
|
+
constructor(device: GPUDevice, options?: Partial<WebGPUInstanceStorageOptions>);
|
|
29
|
+
plan(instanceCount: number, recordBytes?: number): readonly ICEInstanceStoragePagePlan[];
|
|
30
|
+
retain(batch: ICEInstanceBatch, geometry: ICEGeometry): ICEInstanceStorageEntry;
|
|
31
|
+
beginFrame(): void;
|
|
32
|
+
endFrame(): void;
|
|
33
|
+
get generation(): number;
|
|
34
|
+
get totalBytes(): number;
|
|
35
|
+
get totalUploadBytes(): number;
|
|
36
|
+
dispose(): void;
|
|
37
|
+
private delete;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=WebGPUInstanceStorage.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WebGPUGeometryCache } from './WebGPUGeometryCache.js';
|
|
2
|
+
import type { ICEFrame, ICEScreenPoint } from './types.js';
|
|
3
|
+
type ICEPickFrame = ICEFrame & {
|
|
4
|
+
readonly point: ICEScreenPoint;
|
|
5
|
+
};
|
|
6
|
+
export declare class WebGPUPicker {
|
|
7
|
+
private readonly device;
|
|
8
|
+
private readonly pipelinePromise;
|
|
9
|
+
private readonly instanceCache;
|
|
10
|
+
private readonly identityInstances;
|
|
11
|
+
private readonly zeroSemantics;
|
|
12
|
+
private readonly renderPlan;
|
|
13
|
+
private target;
|
|
14
|
+
private depth;
|
|
15
|
+
private uniformBuffer;
|
|
16
|
+
private width;
|
|
17
|
+
private height;
|
|
18
|
+
private disposed;
|
|
19
|
+
constructor(device: GPUDevice, format: GPUTextureFormat);
|
|
20
|
+
pick(frame: ICEPickFrame, geometryCache: WebGPUGeometryCache, pickIds: Readonly<Record<number, string>>): Promise<string | undefined>;
|
|
21
|
+
resize(width: number, height: number): void;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
private ensureTarget;
|
|
24
|
+
private ensureUniformBuffer;
|
|
25
|
+
private uniformBufferCapacity;
|
|
26
|
+
private uniformBufferDraws;
|
|
27
|
+
}
|
|
28
|
+
export declare function collectWebGPUPickIds(frame: ICEFrame): Readonly<Record<number, string>>;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=WebGPUPicker.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ICEWebGPUProbeFailureReason = 'document-unavailable' | 'api-unavailable' | 'adapter-unavailable' | 'adapter-timeout' | 'feature-missing' | 'limit-too-low' | 'device-failed' | 'context-failed' | 'pipeline-failed' | 'device-lost';
|
|
2
|
+
export type ICEWebGPUProbeResult = {
|
|
3
|
+
readonly supported: true;
|
|
4
|
+
readonly adapter: GPUAdapter;
|
|
5
|
+
readonly device: GPUDevice;
|
|
6
|
+
readonly format: GPUTextureFormat;
|
|
7
|
+
readonly enabledFeatures: ReadonlySet<GPUFeatureName>;
|
|
8
|
+
readonly release: () => void;
|
|
9
|
+
} | {
|
|
10
|
+
readonly supported: false;
|
|
11
|
+
readonly reason: ICEWebGPUProbeFailureReason;
|
|
12
|
+
readonly detail?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ICEWebGPUProbeOptions = {
|
|
15
|
+
readonly gpu?: GPU;
|
|
16
|
+
readonly timeoutMs?: number;
|
|
17
|
+
readonly createCanvas?: () => OffscreenCanvas | HTMLCanvasElement;
|
|
18
|
+
readonly optionalFeatures?: readonly GPUFeatureName[];
|
|
19
|
+
};
|
|
20
|
+
export declare function probeWebGPU(options?: ICEWebGPUProbeOptions): Promise<ICEWebGPUProbeResult>;
|
|
21
|
+
//# sourceMappingURL=WebGPUProbe.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const WEBGPU_UNIFORM_STRIDE = 256;
|
|
2
|
+
export declare const WEBGPU_UNIFORM_BYTES = 128;
|
|
3
|
+
export declare class WebGPURenderPipeline {
|
|
4
|
+
readonly device: GPUDevice;
|
|
5
|
+
readonly format: GPUTextureFormat;
|
|
6
|
+
readonly bindGroupLayout: GPUBindGroupLayout;
|
|
7
|
+
readonly pipelineLayout: GPUPipelineLayout;
|
|
8
|
+
readonly triangle: GPURenderPipeline;
|
|
9
|
+
readonly line: GPURenderPipeline;
|
|
10
|
+
readonly selectionTriangle: GPURenderPipeline;
|
|
11
|
+
readonly selectionLine: GPURenderPipeline;
|
|
12
|
+
readonly selectionMask: boolean;
|
|
13
|
+
readonly storageInstances: boolean;
|
|
14
|
+
readonly indirectInstances: boolean;
|
|
15
|
+
private constructor();
|
|
16
|
+
static create(device: GPUDevice, format: GPUTextureFormat, options?: {
|
|
17
|
+
readonly selectionMask?: boolean;
|
|
18
|
+
readonly storageInstances?: boolean;
|
|
19
|
+
readonly indirectInstances?: boolean;
|
|
20
|
+
}): Promise<WebGPURenderPipeline>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=WebGPURenderPipeline.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ICEScene } from '../core/index.js';
|
|
2
|
+
import { type ICEGeometryRenderable } from './Renderables.js';
|
|
3
|
+
import { type ICEInstanceBatch } from './InstanceBatch.js';
|
|
4
|
+
import { type ICERenderBatchDraw } from './RenderBatch.js';
|
|
5
|
+
export type WebGPURenderPlan = Readonly<{
|
|
6
|
+
scene: ICEScene;
|
|
7
|
+
revision: number;
|
|
8
|
+
renderables: readonly ICEGeometryRenderable[];
|
|
9
|
+
instances: readonly ICEInstanceBatch[];
|
|
10
|
+
batches: readonly ICERenderBatchDraw[];
|
|
11
|
+
instancedMeshIds: ReadonlySet<string>;
|
|
12
|
+
}>;
|
|
13
|
+
export declare class WebGPURenderPlanCache {
|
|
14
|
+
private scene;
|
|
15
|
+
private current;
|
|
16
|
+
private readonly renderablesScratch;
|
|
17
|
+
private readonly instancesScratch;
|
|
18
|
+
private readonly batchesScratch;
|
|
19
|
+
get(scene: ICEScene): WebGPURenderPlan;
|
|
20
|
+
invalidate(): void;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=WebGPURenderPlan.d.ts.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ICEEngineError, type ICEGeometry } from '../core/index.js';
|
|
2
|
+
import type { ICERendererBackend, ICERendererCapabilities, ICEFrame, ICEViewport } from './types.js';
|
|
3
|
+
import { type ICEFrameStageProfile } from './RendererProfiler.js';
|
|
4
|
+
import { type ICEWebGPUOptimizationStats } from './WebGPUCapabilities.js';
|
|
5
|
+
import type { ICEScreenPoint } from './types.js';
|
|
6
|
+
export type WebGPUDeviceContext = Readonly<{
|
|
7
|
+
adapter: GPUAdapter;
|
|
8
|
+
device: GPUDevice;
|
|
9
|
+
format: GPUTextureFormat;
|
|
10
|
+
release?: () => void;
|
|
11
|
+
}>;
|
|
12
|
+
export type WebGPURendererBackendOptions = Readonly<{
|
|
13
|
+
readonly forceStoragePath?: boolean;
|
|
14
|
+
readonly forceGpuDriven?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
export declare class WebGPURendererBackend implements ICERendererBackend {
|
|
17
|
+
capabilities: Readonly<ICERendererCapabilities>;
|
|
18
|
+
private readonly adapter;
|
|
19
|
+
private device;
|
|
20
|
+
private readonly format;
|
|
21
|
+
private pipeline;
|
|
22
|
+
private storagePipeline;
|
|
23
|
+
private gpuDrivenPipeline;
|
|
24
|
+
private visibilityEncoder;
|
|
25
|
+
private storageCache;
|
|
26
|
+
private readonly acceleration;
|
|
27
|
+
private readonly forceStoragePath;
|
|
28
|
+
private readonly forceGpuDriven;
|
|
29
|
+
private readonly releaseProbe;
|
|
30
|
+
private onContextLost;
|
|
31
|
+
private onContextRestored;
|
|
32
|
+
private onError;
|
|
33
|
+
private disposing;
|
|
34
|
+
private canvas;
|
|
35
|
+
private context;
|
|
36
|
+
private geometryCache;
|
|
37
|
+
private instanceCache;
|
|
38
|
+
private picker;
|
|
39
|
+
private selectionMaskBuffer;
|
|
40
|
+
private timestampProfiler;
|
|
41
|
+
private timestampProfilingEnabled;
|
|
42
|
+
private bundleCache;
|
|
43
|
+
private bundleActive;
|
|
44
|
+
private frameBindGroup;
|
|
45
|
+
private frameBindGroupKey;
|
|
46
|
+
private readonly storageBindGroups;
|
|
47
|
+
private uniformBufferGeneration;
|
|
48
|
+
private readonly optimizationWarnings;
|
|
49
|
+
private identityInstances;
|
|
50
|
+
private zeroSemantics;
|
|
51
|
+
private uniformBuffer;
|
|
52
|
+
private depthTexture;
|
|
53
|
+
private uniformCapacity;
|
|
54
|
+
private viewport;
|
|
55
|
+
private dpr;
|
|
56
|
+
private backgroundRgba;
|
|
57
|
+
private frameStats;
|
|
58
|
+
private lastFrame;
|
|
59
|
+
private captureRequest;
|
|
60
|
+
private readonly renderPlan;
|
|
61
|
+
private readonly drawListScratch;
|
|
62
|
+
private readonly selected;
|
|
63
|
+
private readonly drawStorage;
|
|
64
|
+
private readonly lastVisibilityEntries;
|
|
65
|
+
private readonly mvpScratch;
|
|
66
|
+
private readonly worldScratch;
|
|
67
|
+
private readonly profiler;
|
|
68
|
+
private lastFrameProfile;
|
|
69
|
+
private optimizationFailureReason;
|
|
70
|
+
private storageFailureReason;
|
|
71
|
+
private visibilityFailureReason;
|
|
72
|
+
private constructor();
|
|
73
|
+
static create(context: WebGPUDeviceContext, options?: WebGPURendererBackendOptions): Promise<WebGPURendererBackend>;
|
|
74
|
+
initialize(options: {
|
|
75
|
+
readonly canvas: HTMLCanvasElement;
|
|
76
|
+
readonly onContextLost?: () => void;
|
|
77
|
+
readonly onContextRestored?: () => void;
|
|
78
|
+
readonly onError?: (error: ICEEngineError) => void;
|
|
79
|
+
}): void;
|
|
80
|
+
resize(viewport: ICEViewport, dpr: number): void;
|
|
81
|
+
setBackgroundColor(color: string): void;
|
|
82
|
+
prepareBatchGeometry(geometry: ICEGeometry): void;
|
|
83
|
+
releaseBatchGeometry(geometry: ICEGeometry): void;
|
|
84
|
+
render(frame: ICEFrame): void;
|
|
85
|
+
enableProfiling(enabled: boolean): void;
|
|
86
|
+
get frameProfile(): ICEFrameStageProfile | null;
|
|
87
|
+
pick(frame: ICEFrame, point: ICEScreenPoint): Promise<string | undefined>;
|
|
88
|
+
dispose(): void;
|
|
89
|
+
capture(): Promise<Blob>;
|
|
90
|
+
finish(): Promise<void>;
|
|
91
|
+
drainGpuTimings(): Promise<readonly number[]>;
|
|
92
|
+
enableTimestampProfiling(enabled: boolean): void;
|
|
93
|
+
get timestampProfilingAvailable(): boolean;
|
|
94
|
+
get timestampProfilingUnavailableReason(): string | undefined;
|
|
95
|
+
get stats(): Readonly<typeof this.frameStats>;
|
|
96
|
+
readVisibilityStats(): Promise<Readonly<{
|
|
97
|
+
visibleInstances: number;
|
|
98
|
+
culledInstances: number;
|
|
99
|
+
dispatchCount: number;
|
|
100
|
+
}> | undefined>;
|
|
101
|
+
get storageActive(): boolean;
|
|
102
|
+
private get gpuDrivenActive();
|
|
103
|
+
get optimizationStats(): ICEWebGPUOptimizationStats;
|
|
104
|
+
private storageBindGroupFor;
|
|
105
|
+
private reportOptimizationFailure;
|
|
106
|
+
private requireGeometryCache;
|
|
107
|
+
private ensureUniformCapacity;
|
|
108
|
+
private watchDevice;
|
|
109
|
+
private recoverDevice;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=WebGPURendererBackend.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const WEBGPU_BUFFER_USAGE: {
|
|
2
|
+
readonly vertex: number;
|
|
3
|
+
readonly index: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function alignToFourBytes(value: number): number;
|
|
6
|
+
export declare function createGPUDataBuffer(device: GPUDevice, data: ArrayBufferView, usage: GPUBufferUsageFlags, label: string): GPUBuffer;
|
|
7
|
+
export declare function createEmptyGPUDataBuffer(device: GPUDevice, byteLength: number, usage: GPUBufferUsageFlags, label: string): GPUBuffer;
|
|
8
|
+
export declare function writeGPUData(device: GPUDevice, buffer: GPUBuffer, data: ArrayBufferView): void;
|
|
9
|
+
//# sourceMappingURL=WebGPUResources.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ICESelectionMaskLayout = Readonly<{
|
|
2
|
+
words: Uint32Array;
|
|
3
|
+
bases: readonly number[];
|
|
4
|
+
}>;
|
|
5
|
+
export declare function buildSelectionMask(ranges: readonly (readonly string[])[], selection: readonly string[]): ICESelectionMaskLayout;
|
|
6
|
+
export declare class WebGPUSelectionMaskBuffer {
|
|
7
|
+
private readonly device;
|
|
8
|
+
private maskBuffer;
|
|
9
|
+
private previous;
|
|
10
|
+
private maskGeneration;
|
|
11
|
+
constructor(device: GPUDevice);
|
|
12
|
+
get buffer(): GPUBuffer | null;
|
|
13
|
+
get generation(): number;
|
|
14
|
+
get totalBytes(): number;
|
|
15
|
+
update(words: Uint32Array): void;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=WebGPUSelectionMask.d.ts.map
|