ice3 0.2.0 → 0.2.2
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 +7 -6
- package/dist/_types/assets/ICEGLBReader.d.ts +8 -1
- package/dist/_types/assets/ICEPreparedGLB.d.ts +26 -0
- package/dist/_types/assets/ICEPreviewGeometryPacket.d.ts +60 -0
- package/dist/_types/assets/index.d.ts +3 -0
- package/dist/_types/core/camera/ICEPerspectiveCamera.d.ts +8 -2
- package/dist/_types/core/geometry/ICEGeometry.d.ts +13 -0
- package/dist/_types/core/geometry/ICEIndexedGeometry.d.ts +3 -1
- package/dist/_types/core/index.d.ts +2 -2
- package/dist/_types/core/material/ICEBasicMaterial.d.ts +52 -0
- package/dist/_types/renderer/InstanceBatch.d.ts +7 -0
- package/dist/_types/renderer/SceneBounds.d.ts +16 -0
- package/dist/_types/renderer/ShadowFrustum.d.ts +20 -0
- package/dist/_types/renderer/WebGL2DepthMath.d.ts +22 -0
- package/dist/_types/renderer/WebGL2GeometryCache.d.ts +16 -2
- package/dist/_types/renderer/WebGL2InstanceBatch.d.ts +1 -1
- package/dist/_types/renderer/WebGL2Program.d.ts +68 -0
- package/dist/_types/renderer/WebGL2RendererBackend.d.ts +44 -0
- package/dist/_types/renderer/WebGL2SceneDepth.d.ts +19 -0
- package/dist/_types/renderer/WebGL2Shader.d.ts +11 -0
- package/dist/_types/renderer/WebGL2ShadowMap.d.ts +42 -0
- package/dist/_types/renderer/WebGL2TextureCache.d.ts +31 -0
- package/dist/_types/renderer/WebGL2Uv.d.ts +16 -0
- package/dist/_types/renderer/WebGPUDrawStorage.d.ts +1 -0
- package/dist/_types/renderer/WebGPUGeometryCache.d.ts +16 -2
- package/dist/_types/renderer/WebGPURenderPipeline.d.ts +1 -1
- package/dist/_types/renderer/WebGPURendererBackend.d.ts +2 -0
- package/dist/_types/renderer/index.d.ts +1 -1
- package/dist/_types/renderer/types.d.ts +9 -1
- package/dist/_types/runtime/ICE3.d.ts +8 -0
- package/dist/_types/runtime/asset/ICEAssetSceneBuilder.d.ts +8 -2
- package/dist/_types/runtime/asset/ICEPreviewPacketLoader.d.ts +25 -0
- package/dist/_types/runtime/asset/ICETilesetLoader.d.ts +0 -1
- package/dist/_types/runtime/index.d.ts +2 -1
- package/dist/_types/runtime/input/ICEOrbitController.d.ts +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2742 -242
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
ICE3 是面向工业场景的浏览器 3D Runtime。公开代码通过单向 facade 暴露 Scene、
|
|
10
10
|
Geometry、Camera、Asset 和 Tileset API。
|
|
11
11
|
|
|
12
|
-
## 安装
|
|
12
|
+
## 1. 安装
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
15
|
npm install ice3
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
## 最小使用
|
|
18
|
+
## 2. 最小使用
|
|
19
19
|
|
|
20
20
|
```ts
|
|
21
21
|
import {
|
|
@@ -54,9 +54,10 @@ WebGL2 兼容别名。拾取使用 `await engine.pick(point)`。
|
|
|
54
54
|
完整文档和相关工具见
|
|
55
55
|
[Engine 文档](https://github.com/ice-3d/ice3-engine/blob/main/README.md)。
|
|
56
56
|
|
|
57
|
-
工业模型接入 Runtime
|
|
58
|
-
[ICE3
|
|
59
|
-
|
|
60
|
-
[
|
|
57
|
+
工业模型接入 Runtime 前,使用
|
|
58
|
+
[ICE3 Studio](https://github.com/ice-3d/ice3-studio/blob/main/README.md)
|
|
59
|
+
完成 Source Import、Prepare、验证、partition、LOD 和 Tileset 发布。当前生产链见
|
|
60
|
+
[Studio Asset Pipeline](https://github.com/ice-3d/ice3-studio/blob/main/docs/reference/asset-pipeline.md)。
|
|
61
|
+
公开 package 的当前版本为 `0.2.2`。
|
|
61
62
|
|
|
62
63
|
本项目采用 MIT License。
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { ICEPreparedAssetSnapshot } from './ICEPreparedGLB.js';
|
|
2
|
-
export
|
|
2
|
+
export interface ICEPreparedReadOptions {
|
|
3
|
+
/**
|
|
4
|
+
* URL the GLB was loaded from. Texture images are resolved against it, as
|
|
5
|
+
* glTF requires external resources to be relative to the referencing file.
|
|
6
|
+
*/
|
|
7
|
+
readonly baseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function readPreparedGLB(bytes: ArrayBuffer, options?: ICEPreparedReadOptions): ICEPreparedAssetSnapshot;
|
|
3
10
|
export declare function verifyPreparedGLBIntegrity(bytes: ArrayBuffer): Promise<boolean>;
|
|
4
11
|
//# sourceMappingURL=ICEGLBReader.d.ts.map
|
|
@@ -21,6 +21,32 @@ export interface ICEPreparedMaterial {
|
|
|
21
21
|
readonly id: string;
|
|
22
22
|
readonly baseColor: string;
|
|
23
23
|
readonly edgeColor?: string;
|
|
24
|
+
readonly shading?: 'directional' | 'flat' | 'water';
|
|
25
|
+
/** Base-colour texture resolved from the source glTF. */
|
|
26
|
+
readonly map?: {
|
|
27
|
+
readonly url: string;
|
|
28
|
+
readonly scale?: readonly [number, number];
|
|
29
|
+
};
|
|
30
|
+
/** Tangent-space normal map. */
|
|
31
|
+
readonly normalMap?: {
|
|
32
|
+
readonly url: string;
|
|
33
|
+
readonly strength?: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Packed ORM map: R occlusion, G roughness, B metallic. A glTF may ship the
|
|
37
|
+
* two halves as separate slots; when they resolve to the same image the
|
|
38
|
+
* renderer samples it once.
|
|
39
|
+
*/
|
|
40
|
+
readonly ormMap?: {
|
|
41
|
+
readonly url: string;
|
|
42
|
+
readonly scale?: readonly [number, number];
|
|
43
|
+
readonly occlusion: boolean;
|
|
44
|
+
readonly metallicRoughness: boolean;
|
|
45
|
+
};
|
|
46
|
+
/** Metallic-roughness factors straight from the glTF material. */
|
|
47
|
+
readonly metallic?: number;
|
|
48
|
+
readonly roughness?: number;
|
|
49
|
+
readonly emissive?: readonly [number, number, number];
|
|
24
50
|
}
|
|
25
51
|
export interface ICEPreparedMesh {
|
|
26
52
|
readonly id: string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type ICEPreviewGeometryBackend = 'cpu' | 'gpu';
|
|
2
|
+
export type ICEPreviewGeometryResidencyMode = 'cpu' | 'cold' | 'warm' | 'resident' | 'snapshot';
|
|
3
|
+
export type ICEPreviewGeometryRangeUsage = 'vertex_attributes' | 'indices';
|
|
4
|
+
export interface ICEPreviewGeometryRange {
|
|
5
|
+
readonly byteOffset: number;
|
|
6
|
+
readonly byteLength: number;
|
|
7
|
+
readonly usage: ICEPreviewGeometryRangeUsage;
|
|
8
|
+
}
|
|
9
|
+
export interface ICEPreviewGeometryNode {
|
|
10
|
+
readonly nodeId: string;
|
|
11
|
+
readonly parentId: string | null;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly matrix: readonly number[];
|
|
14
|
+
readonly materialId: string | null;
|
|
15
|
+
readonly geometryId: string | null;
|
|
16
|
+
readonly visible: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ICEPreviewGeometryRecord {
|
|
19
|
+
readonly geometryId: string;
|
|
20
|
+
readonly residentGeometryId: string | null;
|
|
21
|
+
readonly topologyDigest: string;
|
|
22
|
+
readonly attributeDigest: string;
|
|
23
|
+
readonly vertexCount: number;
|
|
24
|
+
readonly indexCount: number;
|
|
25
|
+
readonly indexWidth: 2 | 4;
|
|
26
|
+
readonly ranges: readonly ICEPreviewGeometryRange[];
|
|
27
|
+
}
|
|
28
|
+
export interface ICEPreviewGeometry extends ICEPreviewGeometryRecord {
|
|
29
|
+
readonly positions: Float32Array;
|
|
30
|
+
readonly indices: Uint16Array | Uint32Array;
|
|
31
|
+
}
|
|
32
|
+
export interface ICEPreviewGeometryMaterial {
|
|
33
|
+
readonly materialId: string;
|
|
34
|
+
readonly baseColor: readonly [number, number, number, number];
|
|
35
|
+
readonly metallic: number;
|
|
36
|
+
readonly roughness: number;
|
|
37
|
+
readonly opacity: number;
|
|
38
|
+
}
|
|
39
|
+
export interface ICEPreviewGeometryManifest {
|
|
40
|
+
readonly schemaVersion: number;
|
|
41
|
+
readonly transportVersion: number;
|
|
42
|
+
readonly revision: number;
|
|
43
|
+
readonly parentRevision: number | null;
|
|
44
|
+
readonly sourceDigest: string;
|
|
45
|
+
readonly backend: ICEPreviewGeometryBackend;
|
|
46
|
+
readonly residencyMode: ICEPreviewGeometryResidencyMode;
|
|
47
|
+
readonly nodes: readonly ICEPreviewGeometryNode[];
|
|
48
|
+
readonly geometries: readonly ICEPreviewGeometryRecord[];
|
|
49
|
+
readonly materials: readonly ICEPreviewGeometryMaterial[];
|
|
50
|
+
readonly removedNodeIds: readonly string[];
|
|
51
|
+
readonly removedGeometryIds: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
export interface ICEPreviewGeometryPacket extends Omit<ICEPreviewGeometryManifest, 'geometries'> {
|
|
54
|
+
readonly geometries: readonly ICEPreviewGeometry[];
|
|
55
|
+
readonly binary: Uint8Array;
|
|
56
|
+
}
|
|
57
|
+
export type ICEPreviewGeometryDelta = ICEPreviewGeometryPacket;
|
|
58
|
+
export declare function parsePreviewGeometryPacket(input: Uint8Array | ArrayBuffer): ICEPreviewGeometryPacket;
|
|
59
|
+
export declare function applyPreviewGeometryDelta(base: ICEPreviewGeometryPacket, delta: ICEPreviewGeometryDelta): ICEPreviewGeometryPacket;
|
|
60
|
+
//# sourceMappingURL=ICEPreviewGeometryPacket.d.ts.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { readPreparedGLB, verifyPreparedGLBIntegrity, } from './ICEGLBReader.js';
|
|
2
|
+
export type { ICEPreparedReadOptions } from './ICEGLBReader.js';
|
|
2
3
|
export type { ICEPreparedAssetSnapshot, ICEPreparedBatch, ICEPreparedBatching, ICEPreparedContract, ICEPreparedGeometry, ICEPreparedMaterial, ICEPreparedMesh, ICEPreparedNode, ICEPreparedStats, } from './ICEPreparedGLB.js';
|
|
4
|
+
export { applyPreviewGeometryDelta, parsePreviewGeometryPacket, } from './ICEPreviewGeometryPacket.js';
|
|
5
|
+
export type { ICEPreviewGeometry, ICEPreviewGeometryBackend, ICEPreviewGeometryDelta, ICEPreviewGeometryManifest, ICEPreviewGeometryMaterial, ICEPreviewGeometryNode, ICEPreviewGeometryPacket, ICEPreviewGeometryRange, ICEPreviewGeometryRangeUsage, ICEPreviewGeometryRecord, ICEPreviewGeometryResidencyMode, } from './ICEPreviewGeometryPacket.js';
|
|
3
6
|
export { readTileset } from './ICETilesetReader.js';
|
|
4
7
|
export type { ICETilesetSnapshot, ICETilesetTile, } from './ICETileset.js';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -11,15 +11,21 @@ export interface ICEPerspectiveCameraOptions {
|
|
|
11
11
|
export declare class ICEPerspectiveCamera {
|
|
12
12
|
readonly id: string;
|
|
13
13
|
readonly fov: number;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
near: number;
|
|
15
|
+
far: number;
|
|
16
16
|
private eye;
|
|
17
17
|
private lookTarget;
|
|
18
18
|
constructor(options: ICEPerspectiveCameraOptions);
|
|
19
19
|
setPosition(position: ICEVector3Tuple): this;
|
|
20
20
|
setTarget(target: ICEVector3Tuple): this;
|
|
21
|
+
setClipPlanes(near: number, far: number): this;
|
|
21
22
|
getPosition(): ICEVector3;
|
|
22
23
|
getTarget(): ICEVector3;
|
|
24
|
+
/**
|
|
25
|
+
* 投影矩阵。屏幕空间效果要从深度重建视空间坐标,光有 viewProjection 不够。
|
|
26
|
+
*/
|
|
27
|
+
getProjectionMatrix(aspect: number): ICEMatrix4;
|
|
28
|
+
getViewMatrix(): ICEMatrix4;
|
|
23
29
|
getViewProjectionMatrix(aspect: number): ICEMatrix4;
|
|
24
30
|
}
|
|
25
31
|
//# sourceMappingURL=ICEPerspectiveCamera.d.ts.map
|
|
@@ -2,6 +2,18 @@ export interface ICEGeometryBounds {
|
|
|
2
2
|
readonly min: readonly [number, number, number];
|
|
3
3
|
readonly max: readonly [number, number, number];
|
|
4
4
|
}
|
|
5
|
+
export interface ICEGeometryIdentity {
|
|
6
|
+
readonly geometryId: string;
|
|
7
|
+
readonly topologyDigest: string;
|
|
8
|
+
readonly attributeDigest: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ICEGeometryByteRange {
|
|
11
|
+
readonly byteOffset: number;
|
|
12
|
+
readonly byteLength: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ICEGeometryBufferUpdate {
|
|
15
|
+
readonly positionRanges: readonly ICEGeometryByteRange[];
|
|
16
|
+
}
|
|
5
17
|
export interface ICEGeometry {
|
|
6
18
|
readonly typeId: string;
|
|
7
19
|
readonly positions: Float32Array;
|
|
@@ -9,6 +21,7 @@ export interface ICEGeometry {
|
|
|
9
21
|
readonly edgeIndices?: Uint16Array | Uint32Array;
|
|
10
22
|
readonly colors?: Float32Array;
|
|
11
23
|
readonly semanticIndices?: Uint32Array;
|
|
24
|
+
readonly identity?: ICEGeometryIdentity;
|
|
12
25
|
getBounds(): ICEGeometryBounds;
|
|
13
26
|
toJSON(): Record<string, unknown>;
|
|
14
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ICEGeometry, ICEGeometryBounds } from './ICEGeometry.js';
|
|
1
|
+
import type { ICEGeometry, ICEGeometryBounds, ICEGeometryIdentity } from './ICEGeometry.js';
|
|
2
2
|
export interface ICEIndexedGeometryOptions {
|
|
3
3
|
readonly id: string;
|
|
4
4
|
readonly positions: Float32Array;
|
|
@@ -6,6 +6,7 @@ export interface ICEIndexedGeometryOptions {
|
|
|
6
6
|
readonly edgeIndices?: Uint16Array | Uint32Array;
|
|
7
7
|
readonly colors?: Float32Array;
|
|
8
8
|
readonly semanticIndices?: Uint32Array;
|
|
9
|
+
readonly identity?: ICEGeometryIdentity;
|
|
9
10
|
}
|
|
10
11
|
export declare class ICEIndexedGeometry implements ICEGeometry {
|
|
11
12
|
readonly typeId = "ice3:IndexedGeometry";
|
|
@@ -15,6 +16,7 @@ export declare class ICEIndexedGeometry implements ICEGeometry {
|
|
|
15
16
|
readonly edgeIndices?: Uint16Array | Uint32Array;
|
|
16
17
|
readonly colors?: Float32Array;
|
|
17
18
|
readonly semanticIndices?: Uint32Array;
|
|
19
|
+
readonly identity: ICEGeometryIdentity;
|
|
18
20
|
constructor(options: ICEIndexedGeometryOptions);
|
|
19
21
|
getBounds(): ICEGeometryBounds;
|
|
20
22
|
toJSON(): Record<string, unknown>;
|
|
@@ -7,9 +7,9 @@ export { ICEBoxGeometry } from './geometry/ICEBoxGeometry.js';
|
|
|
7
7
|
export type { ICEBoxGeometryOptions } from './geometry/ICEBoxGeometry.js';
|
|
8
8
|
export { ICEIndexedGeometry } from './geometry/ICEIndexedGeometry.js';
|
|
9
9
|
export type { ICEIndexedGeometryOptions } from './geometry/ICEIndexedGeometry.js';
|
|
10
|
-
export type { ICEGeometry, ICEGeometryBounds } from './geometry/ICEGeometry.js';
|
|
10
|
+
export type { ICEGeometry, ICEGeometryBounds, ICEGeometryBufferUpdate, ICEGeometryByteRange, ICEGeometryIdentity, } from './geometry/ICEGeometry.js';
|
|
11
11
|
export { ICEBasicMaterial } from './material/ICEBasicMaterial.js';
|
|
12
|
-
export type { ICEBasicMaterialOptions } from './material/ICEBasicMaterial.js';
|
|
12
|
+
export type { ICEBasicMaterialMap, ICEBasicMaterialNormalMap, ICEBasicMaterialOptions, ICEBasicMaterialOrmMap, } from './material/ICEBasicMaterial.js';
|
|
13
13
|
export { ICEPerspectiveCamera } from './camera/ICEPerspectiveCamera.js';
|
|
14
14
|
export type { ICEPerspectiveCameraOptions } from './camera/ICEPerspectiveCamera.js';
|
|
15
15
|
export { ICEFrustum } from './culling/ICEFrustum.js';
|
|
@@ -1,11 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base-colour texture reference.
|
|
3
|
+
*
|
|
4
|
+
* `url` points at an image the renderer loads asynchronously; `scale` tiles it
|
|
5
|
+
* over the metre-based UV projection (`[1,1]` means one texture repeat per metre).
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_ROUGHNESS = 0.85;
|
|
8
|
+
export interface ICEBasicMaterialMap {
|
|
9
|
+
readonly url: string;
|
|
10
|
+
readonly scale?: readonly [number, number];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Tangent-space normal map.
|
|
14
|
+
*
|
|
15
|
+
* `strength` multiplies the sampled X/Y perturbation, matching glTF's
|
|
16
|
+
* `normalTexture.scale`; 1 is neutral.
|
|
17
|
+
*/
|
|
18
|
+
export interface ICEBasicMaterialNormalMap {
|
|
19
|
+
readonly url: string;
|
|
20
|
+
readonly strength?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Packed occlusion / roughness / metallic map, the glTF ORM layout:
|
|
24
|
+
* R = ambient occlusion, G = roughness, B = metallic.
|
|
25
|
+
*
|
|
26
|
+
* `occlusion` and `metallicRoughness` say which channels the image actually
|
|
27
|
+
* carries — an exporter may ship only the metallic-roughness half, and using the
|
|
28
|
+
* R channel then would darken surfaces for no reason.
|
|
29
|
+
*/
|
|
30
|
+
export interface ICEBasicMaterialOrmMap {
|
|
31
|
+
readonly url: string;
|
|
32
|
+
readonly scale?: readonly [number, number];
|
|
33
|
+
readonly occlusion?: boolean;
|
|
34
|
+
readonly metallicRoughness?: boolean;
|
|
35
|
+
}
|
|
1
36
|
export interface ICEBasicMaterialOptions {
|
|
2
37
|
readonly color: string;
|
|
3
38
|
readonly edgeColor?: string;
|
|
39
|
+
readonly shading?: 'directional' | 'flat' | 'water';
|
|
40
|
+
readonly map?: ICEBasicMaterialMap;
|
|
41
|
+
readonly normalMap?: ICEBasicMaterialNormalMap;
|
|
42
|
+
readonly ormMap?: ICEBasicMaterialOrmMap;
|
|
43
|
+
/** 0 = dielectric, 1 = metal. Drives the specular tint and strength. */
|
|
44
|
+
readonly metallic?: number;
|
|
45
|
+
/** 0 = mirror-smooth highlight, 1 = broad and dull. */
|
|
46
|
+
readonly roughness?: number;
|
|
47
|
+
/** Linear RGB emitted by the surface, added after lighting. */
|
|
48
|
+
readonly emissive?: readonly [number, number, number];
|
|
4
49
|
}
|
|
5
50
|
export declare class ICEBasicMaterial {
|
|
6
51
|
readonly typeId = "ice3:BasicMaterial";
|
|
7
52
|
readonly color: string;
|
|
8
53
|
readonly edgeColor: string | undefined;
|
|
54
|
+
readonly shading: 'directional' | 'flat' | 'water' | undefined;
|
|
55
|
+
readonly map: ICEBasicMaterialMap | undefined;
|
|
56
|
+
readonly normalMap: ICEBasicMaterialNormalMap | undefined;
|
|
57
|
+
readonly ormMap: ICEBasicMaterialOrmMap | undefined;
|
|
58
|
+
readonly metallic: number;
|
|
59
|
+
readonly roughness: number;
|
|
60
|
+
readonly emissive: readonly [number, number, number] | undefined;
|
|
9
61
|
constructor(options: ICEBasicMaterialOptions);
|
|
10
62
|
toJSON(): Record<string, unknown>;
|
|
11
63
|
}
|
|
@@ -11,4 +11,11 @@ export interface ICEInstanceBatch {
|
|
|
11
11
|
readonly materialKey: string;
|
|
12
12
|
}
|
|
13
13
|
export declare function collectInstanceBatches(renderables: readonly ICEGeometryRenderable[], output?: ICEInstanceBatch[]): readonly ICEInstanceBatch[];
|
|
14
|
+
/**
|
|
15
|
+
* 落单的网格:几何与材质组合只出现一次,实例化省不下开销,主通道仍按单体绘制。
|
|
16
|
+
*
|
|
17
|
+
* 单独抽出来是因为**每个附加通道都要画同一批东西**。深度通道漏掉这一条,
|
|
18
|
+
* 落单的网格就既不参与遮挡也不接收遮蔽(SPEC-007 第 5 节)。
|
|
19
|
+
*/
|
|
20
|
+
export declare function renderablesOutsideInstanceBatches(renderables: readonly ICEGeometryRenderable[], batches: readonly ICEInstanceBatch[]): ICEGeometryRenderable[];
|
|
14
21
|
//# sourceMappingURL=InstanceBatch.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ICEGeometry } from '../core/index.js';
|
|
2
|
+
import type { ICEGeometryRenderable } from './Renderables.js';
|
|
3
|
+
import type { ICEBounds } from './ShadowFrustum.js';
|
|
4
|
+
type LocalBounds = Readonly<{
|
|
5
|
+
min: readonly [number, number, number];
|
|
6
|
+
max: readonly [number, number, number];
|
|
7
|
+
}>;
|
|
8
|
+
/** 几何的局部包围盒:只在首次见到该几何时扫描一遍顶点。 */
|
|
9
|
+
export declare function geometryLocalBounds(geometry: ICEGeometry): LocalBounds | null;
|
|
10
|
+
/**
|
|
11
|
+
* 累加所有可渲染网格的世界包围盒。返回 `null` 表示场景是空的,
|
|
12
|
+
* 调用方应退回默认视锥而不是用空盒子去拟合(否则视锥退化成一条线)。
|
|
13
|
+
*/
|
|
14
|
+
export declare function accumulateSceneBounds(renderables: readonly ICEGeometryRenderable[]): ICEBounds | null;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=SceneBounds.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ICEBounds = Readonly<{
|
|
2
|
+
min: readonly [number, number, number];
|
|
3
|
+
max: readonly [number, number, number];
|
|
4
|
+
}>;
|
|
5
|
+
/** 光源方向(与主着色器、阴影 pass 共用同一约定:指向"光传播"的方向)。 */
|
|
6
|
+
export declare const SHADOW_LIGHT_DIRECTION: readonly [number, number, number];
|
|
7
|
+
export type ICEShadowFrustum = Readonly<{
|
|
8
|
+
/** 光照视图投影矩阵(列主序 16 元素)。 */
|
|
9
|
+
matrix: Float32Array;
|
|
10
|
+
/** 一个纹素在世界空间里的边长(米):法线偏移量按它来算。 */
|
|
11
|
+
texelWorld: number;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* 场景包围盒 → 光照视图投影矩阵(列主序 16 元素)。
|
|
15
|
+
*
|
|
16
|
+
* 传入 `null` 时退回一个覆盖 600 米场地的默认盒,避免直接抛错:
|
|
17
|
+
* 阴影是可选效果,宁可保守覆盖也不要整帧失败。
|
|
18
|
+
*/
|
|
19
|
+
export declare function shadowFrustum(bounds: ICEBounds | null, mapSize?: number): ICEShadowFrustum;
|
|
20
|
+
//# sourceMappingURL=ShadowFrustum.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type PerspectiveProjection = {
|
|
2
|
+
/** 投影矩阵列主序元素,与 `ICEMatrix4.elements` 一致。 */
|
|
3
|
+
readonly elements: Float32Array | readonly number[];
|
|
4
|
+
readonly near: number;
|
|
5
|
+
readonly far: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* NDC `(x, y, depth)` → 视空间坐标(右手系,相机看向 −Z)。
|
|
9
|
+
*
|
|
10
|
+
* `depth` 取深度缓冲里的值,范围 `[0, 1]`。
|
|
11
|
+
*/
|
|
12
|
+
export declare function viewPositionFromNdc(ndcX: number, ndcY: number, depth: number, projection: PerspectiveProjection): [number, number, number];
|
|
13
|
+
/** 视空间坐标 → NDC;`w` 不为正说明落在相机背面。 */
|
|
14
|
+
export declare function ndcFromViewPosition(position: readonly [number, number, number], projection: PerspectiveProjection): [number, number, number, number];
|
|
15
|
+
/**
|
|
16
|
+
* 视空间半径 → 屏幕像素半径。
|
|
17
|
+
*
|
|
18
|
+
* 用样本点到相机的深度换算,靠近相机时半径自然放大、远处收小;这正是
|
|
19
|
+
* "按视距自适应"要的效果,而且不需要知道世界单位与像素的比例。
|
|
20
|
+
*/
|
|
21
|
+
export declare function screenRadiusForWorldRadius(worldRadius: number, viewDepth: number, viewportHeight: number, projection: PerspectiveProjection): number;
|
|
22
|
+
//# sourceMappingURL=WebGL2DepthMath.d.ts.map
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { ICEGeometry } from '../core/index.js';
|
|
1
|
+
import type { ICEGeometry, ICEGeometryBufferUpdate } from '../core/index.js';
|
|
2
2
|
export interface GeometryEntry {
|
|
3
|
+
geometry: ICEGeometry;
|
|
4
|
+
readonly geometryId: string;
|
|
5
|
+
readonly attributeDigest: string;
|
|
6
|
+
readonly topologyDigest: string;
|
|
3
7
|
readonly vertexArray: WebGLVertexArrayObject;
|
|
4
8
|
readonly positionBuffer: WebGLBuffer;
|
|
5
9
|
readonly triangleIndexBuffer: WebGLBuffer;
|
|
@@ -19,24 +23,34 @@ export declare class WebGL2GeometryCache {
|
|
|
19
23
|
private readonly entries;
|
|
20
24
|
private active;
|
|
21
25
|
private readonly pinned;
|
|
26
|
+
private readonly objectKeys;
|
|
27
|
+
private readonly legacyKeys;
|
|
28
|
+
private objectKeySequence;
|
|
22
29
|
private gl;
|
|
23
30
|
private uploads;
|
|
31
|
+
private updatedBytes;
|
|
24
32
|
private evictions;
|
|
25
33
|
private frameId;
|
|
26
34
|
private readonly inactiveGraceFrames;
|
|
27
35
|
private readonly maxBytes;
|
|
28
36
|
constructor(options?: WebGL2GeometryCacheOptions);
|
|
29
37
|
retain(gl: WebGL2RenderingContext, geometry: ICEGeometry): Readonly<GeometryEntry>;
|
|
38
|
+
private createEntry;
|
|
30
39
|
beginFrame(): void;
|
|
31
|
-
pin(gl: WebGL2RenderingContext, geometry: ICEGeometry): Readonly<GeometryEntry>;
|
|
40
|
+
pin(gl: WebGL2RenderingContext, geometry: ICEGeometry, update?: ICEGeometryBufferUpdate): Readonly<GeometryEntry>;
|
|
32
41
|
unpin(geometry: ICEGeometry): void;
|
|
33
42
|
endFrame(): void;
|
|
34
43
|
clear(): void;
|
|
35
44
|
dispose(): void;
|
|
36
45
|
get totalBytes(): number;
|
|
37
46
|
get uploadCount(): number;
|
|
47
|
+
get updateBytes(): number;
|
|
38
48
|
get evictionCount(): number;
|
|
39
49
|
private deleteEntry;
|
|
40
50
|
private enforceBudget;
|
|
51
|
+
private applyPositionUpdate;
|
|
52
|
+
private canReuse;
|
|
53
|
+
private sameTopology;
|
|
54
|
+
private keyFor;
|
|
41
55
|
}
|
|
42
56
|
//# sourceMappingURL=WebGL2GeometryCache.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebGL2GeometryCache } from './WebGL2GeometryCache.js';
|
|
2
2
|
import type { ICEInstanceBatch } from './InstanceBatch.js';
|
|
3
3
|
export type { ICEGeometryRenderable } from './Renderables.js';
|
|
4
|
-
export { collectInstanceBatches, type ICEInstanceBatch, } from './InstanceBatch.js';
|
|
4
|
+
export { collectInstanceBatches, renderablesOutsideInstanceBatches, type ICEInstanceBatch, } from './InstanceBatch.js';
|
|
5
5
|
export interface WebGL2InstanceEntry {
|
|
6
6
|
readonly vertexArray: WebGLVertexArrayObject;
|
|
7
7
|
readonly matrixBuffer: WebGLBuffer;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { ICEMatrix4 } from '../core/index.js';
|
|
2
|
+
export declare function directionalLightingShade(normal: readonly [number, number, number]): number;
|
|
3
|
+
/**
|
|
4
|
+
* Mirror of the shader's specular curve, exported so the response can be tested
|
|
5
|
+
* without a GPU: smoother surfaces get a tighter, stronger highlight.
|
|
6
|
+
*/
|
|
7
|
+
export declare function specularShininess(roughness: number): number;
|
|
8
|
+
export declare function specularGain(roughness: number): number;
|
|
9
|
+
/** Metals tint their highlight with the base colour; dielectrics stay neutral. */
|
|
10
|
+
export declare function specularReflectance(metallic: number, color: readonly [number, number, number]): [number, number, number];
|
|
2
11
|
export declare class WebGL2Program {
|
|
3
12
|
private readonly gl;
|
|
4
13
|
static readonly POSITION_ATTRIBUTE = 0;
|
|
@@ -10,14 +19,73 @@ export declare class WebGL2Program {
|
|
|
10
19
|
private readonly colorLocation;
|
|
11
20
|
private readonly clipOffsetLocation;
|
|
12
21
|
private readonly vertexColorLocation;
|
|
22
|
+
private readonly directionalShadingLocation;
|
|
23
|
+
private readonly waterShadingLocation;
|
|
24
|
+
private readonly cameraPositionLocation;
|
|
25
|
+
private readonly shadowMapLocation;
|
|
26
|
+
private readonly lightMatrixLocation;
|
|
27
|
+
private readonly shadowEnabledLocation;
|
|
28
|
+
private readonly shadowNormalOffsetLocation;
|
|
29
|
+
private readonly shadowDebugLocation;
|
|
13
30
|
private readonly instancingLocation;
|
|
31
|
+
private readonly pickModeLocation;
|
|
32
|
+
private readonly clipPlaneLocation;
|
|
33
|
+
private readonly baseColorMapLocation;
|
|
34
|
+
private readonly useBaseColorMapLocation;
|
|
35
|
+
private readonly uvScaleLocation;
|
|
36
|
+
private readonly normalMapLocation;
|
|
37
|
+
private readonly ormMapLocation;
|
|
38
|
+
private readonly useOrmMapLocation;
|
|
39
|
+
private readonly ormOcclusionLocation;
|
|
40
|
+
private readonly ormMetallicRoughnessLocation;
|
|
41
|
+
private readonly useNormalMapLocation;
|
|
42
|
+
private readonly normalScaleLocation;
|
|
43
|
+
private readonly metallicLocation;
|
|
44
|
+
private readonly roughnessLocation;
|
|
45
|
+
private readonly emissiveLocation;
|
|
46
|
+
private readonly sceneDepthLocation;
|
|
47
|
+
private readonly useSceneDepthLocation;
|
|
48
|
+
private readonly projectionLocation;
|
|
49
|
+
private readonly viewportLocation;
|
|
50
|
+
private readonly clipRangeLocation;
|
|
51
|
+
private readonly aoRadiusLocation;
|
|
52
|
+
private readonly aoStrengthLocation;
|
|
14
53
|
constructor(gl: WebGL2RenderingContext);
|
|
15
54
|
use(): void;
|
|
16
55
|
setMatrix(matrix: ICEMatrix4): void;
|
|
17
56
|
setColor(color: readonly [number, number, number, number]): void;
|
|
57
|
+
/**
|
|
58
|
+
* Bind a base-colour texture to unit 0 and enable sampling. Passing `null`
|
|
59
|
+
* restores flat shading without touching the bound texture.
|
|
60
|
+
*/
|
|
61
|
+
setBaseColorMap(texture: WebGLTexture | null, scale: readonly [number, number]): void;
|
|
62
|
+
/** Bind a tangent-space normal map to unit 1; `null` disables perturbation. */
|
|
63
|
+
setNormalMap(texture: WebGLTexture | null, strength: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Bind the packed ORM map. `occlusion` / `metallicRoughness` describe which
|
|
66
|
+
* halves of the image are meaningful; both false disables sampling.
|
|
67
|
+
*/
|
|
68
|
+
setOrmMap(texture: WebGLTexture | null, occlusion: boolean, metallicRoughness: boolean): void;
|
|
69
|
+
/** Metallic-roughness factors plus emission for the current draw. */
|
|
70
|
+
setSurface(metallic: number, roughness: number, emissive: readonly [number, number, number] | undefined): void;
|
|
71
|
+
/** 绑定相机深度纹理(unit 2)并传入重建视空间所需的相机参数。 */
|
|
72
|
+
setSceneDepth(texture: WebGLTexture | null, projection: {
|
|
73
|
+
readonly elements: Float32Array;
|
|
74
|
+
} | null, near: number, far: number, deviceWidth: number, deviceHeight: number): void;
|
|
75
|
+
/** 遮蔽半径(米)与强度,供运行时调节。强度 0 等于关闭。 */
|
|
76
|
+
setOcclusion(radius: number, strength: number): void;
|
|
18
77
|
setClipOffset(x: number, y: number): void;
|
|
78
|
+
setClipPlane(plane: readonly [number, number, number, number]): void;
|
|
19
79
|
setVertexColors(enabled: boolean): void;
|
|
80
|
+
/** 绑定阴影贴图与光源矩阵;关闭时着色器跳过采样。 */
|
|
81
|
+
setShadow(enabled: boolean, texture: WebGLTexture | null, matrix: Float32Array | null, normalOffset?: number, unit?: number): void;
|
|
82
|
+
/** 阴影调试通道:0 关闭,1 输出遮蔽判定,2 输出深度图。 */
|
|
83
|
+
setShadowDebug(mode: number): void;
|
|
84
|
+
setDirectionalShading(enabled: boolean): void;
|
|
85
|
+
setWaterShading(enabled: boolean): void;
|
|
86
|
+
setCameraPosition(position: readonly [number, number, number]): void;
|
|
20
87
|
setInstancing(enabled: boolean): void;
|
|
88
|
+
setPickMode(enabled: boolean): void;
|
|
21
89
|
dispose(): void;
|
|
22
90
|
private createProgram;
|
|
23
91
|
private compile;
|
|
@@ -11,6 +11,12 @@ export declare class WebGL2RendererBackend implements ICERendererBackend {
|
|
|
11
11
|
private onContextLost;
|
|
12
12
|
private onContextRestored;
|
|
13
13
|
private program;
|
|
14
|
+
private clipPlane;
|
|
15
|
+
private shadowMap;
|
|
16
|
+
/** 方向光阴影开关:默认关闭,由 `initialize({ shadows })` 或页面地址 `?shadows=` 打开。 */
|
|
17
|
+
private shadowEnabled;
|
|
18
|
+
/** `?shadowdebug=1` 输出遮蔽判定,`=2` 输出深度图;排查阴影问题的唯一可信手段。 */
|
|
19
|
+
private shadowDebug;
|
|
14
20
|
private semanticProgram;
|
|
15
21
|
private geometryCache;
|
|
16
22
|
private instanceCache;
|
|
@@ -25,17 +31,55 @@ export declare class WebGL2RendererBackend implements ICERendererBackend {
|
|
|
25
31
|
private lastFrameProfile;
|
|
26
32
|
private backgroundRgba;
|
|
27
33
|
private frameStats;
|
|
34
|
+
private textures;
|
|
35
|
+
private sceneDepth;
|
|
36
|
+
private occlusionRadius;
|
|
37
|
+
/**
|
|
38
|
+
* 三圈采样比双圈多找到约 1.7 个亮度点的遮蔽(同参数 96.36 → 94.65),原样沿用到
|
|
39
|
+
* 默认值就把厂区压得发闷。0.30 是回调后的值:整帧 95.70(无遮蔽 99.59),
|
|
40
|
+
* 高光像素 878(无遮蔽 1088),接触暗部仍看得见。详见 SPEC-007 第 5.5 节。
|
|
41
|
+
*/
|
|
42
|
+
private occlusionStrength;
|
|
43
|
+
private options;
|
|
44
|
+
/**
|
|
45
|
+
* Bind the material's colour and (if it has one) its base-colour texture.
|
|
46
|
+
* Called for every opaque/shaded draw so a batched draw and a single mesh draw
|
|
47
|
+
* cannot drift apart.
|
|
48
|
+
*/
|
|
49
|
+
private applyMaterial;
|
|
50
|
+
/** Edge overlays are line work: never sampled, always flat. */
|
|
51
|
+
private applyEdgeMaterial;
|
|
52
|
+
/**
|
|
53
|
+
* `?ao=<radius>,<strength>` 覆盖遮蔽参数(`ao=off` 关闭)。
|
|
54
|
+
*
|
|
55
|
+
* 屏幕空间遮蔽的合适参数与场景尺度强相关,靠改代码重编译来找太慢。这里只读一次
|
|
56
|
+
* 页面地址,纯属调参通道,不参与渲染决策。
|
|
57
|
+
*/
|
|
58
|
+
private readOcclusionOverride;
|
|
59
|
+
/**
|
|
60
|
+
* `?shadows=1` / `?shadows=0` 覆盖阴影开关,与 `?ao` 同属调参通道。
|
|
61
|
+
*
|
|
62
|
+
* 阴影是一次额外全场景 pass,默认不开;演示与对比时靠地址栏切换,
|
|
63
|
+
* 不必为看清"有影子/没影子"重编译一次。
|
|
64
|
+
*/
|
|
65
|
+
private readShadowOverride;
|
|
66
|
+
private ensureTextureCache;
|
|
28
67
|
private readonly handleContextLost;
|
|
29
68
|
private readonly handleContextRestored;
|
|
30
69
|
initialize(options: {
|
|
31
70
|
readonly canvas: HTMLCanvasElement;
|
|
32
71
|
readonly onContextLost?: () => void;
|
|
33
72
|
readonly onContextRestored?: () => void;
|
|
73
|
+
readonly onUploadReady?: () => void;
|
|
74
|
+
readonly shadows?: boolean;
|
|
34
75
|
}): void;
|
|
35
76
|
resize(viewport: ICEViewport, dpr: number): void;
|
|
36
77
|
setBackgroundColor(color: string): void;
|
|
37
78
|
prepareBatchGeometry(geometry: ICEGeometry): void;
|
|
79
|
+
prepareGeometry(geometry: ICEGeometry, update?: import('../core/index.js').ICEGeometryBufferUpdate): void;
|
|
80
|
+
releaseGeometry(geometry: ICEGeometry): void;
|
|
38
81
|
releaseBatchGeometry(geometry: ICEGeometry): void;
|
|
82
|
+
setClipPlane(plane: readonly [number, number, number, number] | null): void;
|
|
39
83
|
render(frame: ICEFrame): void;
|
|
40
84
|
enableProfiling(enabled: boolean): void;
|
|
41
85
|
get frameProfile(): ICEFrameStageProfile | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class WebGL2SceneDepth {
|
|
2
|
+
private readonly gl;
|
|
3
|
+
private readonly framebuffer;
|
|
4
|
+
private depthTexture;
|
|
5
|
+
private readonly program;
|
|
6
|
+
private readonly matrixLocation;
|
|
7
|
+
private readonly instancingLocation;
|
|
8
|
+
private width;
|
|
9
|
+
private height;
|
|
10
|
+
constructor(gl: WebGL2RenderingContext);
|
|
11
|
+
get texture(): WebGLTexture | null;
|
|
12
|
+
begin(viewProjection: Float32Array, width: number, height: number): void;
|
|
13
|
+
setMatrix(matrix: Float32Array): void;
|
|
14
|
+
setInstancing(enabled: boolean): void;
|
|
15
|
+
end(width: number, height: number): void;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
private ensureTexture;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=WebGL2SceneDepth.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile and link a program, throwing with the driver's info log on failure.
|
|
3
|
+
*
|
|
4
|
+
* WebGL fails silently: `compileShader`/`linkProgram` only set a status flag, and
|
|
5
|
+
* code that returns `null` on failure turns a shader typo into "this pass simply
|
|
6
|
+
* does nothing". That is exactly how a depth pass can run for two rounds without
|
|
7
|
+
* changing a single pixel (SPEC-007). Every program in the renderer goes through
|
|
8
|
+
* here so a broken shader is loud and quotable.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createShaderProgram(gl: WebGL2RenderingContext, vertexSource: string, fragmentSource: string, label: string): WebGLProgram;
|
|
11
|
+
//# sourceMappingURL=WebGL2Shader.d.ts.map
|