@woosh/meep-engine 2.33.4 → 2.33.5
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/core/bvh2/aabb3/AABB3.js +4 -1
- package/core/collection/array/copyArray.js +2 -2
- package/core/collection/table/RowFirstTableSpec.js +8 -0
- package/core/geom/3d/aabb/aabb3_compute_projected_area.js +1 -0
- package/core/geom/3d/aabb/aabb3_estimate_projected_area2.js +59 -0
- package/core/geom/3d/aabb/aabb3_matrix4_project.js +33 -0
- package/core/geom/3d/aabb/aabb3_matrix4_project.spec.js +41 -0
- package/engine/graphics/GraphicsEngine.js +9 -116
- package/engine/graphics/filter/FlipArrayInPlace.js +25 -0
- package/engine/graphics/filter/FlipArrayViaCanvas.js +13 -0
- package/engine/graphics/filter/ImageFilter.js +20 -51
- package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +1 -1
- package/engine/graphics/micron/prototypeVirtualGeometry.js +1 -1
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +5 -17
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +2 -4
- package/engine/graphics/micron/render/refinement/ActivePatchList.js +33 -25
- package/engine/graphics/micron/render/refinement/ActivePatchRecord.js +4 -2
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +8 -10
- package/engine/graphics/render/forward_plus/LightManager.js +5 -7
- package/engine/graphics/render/forward_plus/data/NumericType.js +9 -0
- package/engine/graphics/render/forward_plus/{TextureBackedMemoryRegion.js → data/TextureBackedMemoryRegion.js} +11 -190
- package/engine/graphics/render/forward_plus/data/channelCountToThreIntegerTextureType.js +16 -0
- package/engine/graphics/render/forward_plus/data/computeDataType.js +36 -0
- package/engine/graphics/render/forward_plus/data/computeThreeTextureFormat.js +18 -0
- package/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +63 -0
- package/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +41 -0
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/engine/graphics/render/visibility/hiz/buffer/HierarchicalZBuffer.js +198 -0
- package/engine/graphics/render/visibility/hiz/buffer/ReductionShader.js +51 -0
- package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +179 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +435 -0
- package/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +174 -0
- package/engine/graphics/render/visibility/hiz/query/QueryShader.js +173 -0
- package/engine/graphics/texture/cubemap/buildCubeURLs.js +13 -0
- package/engine/graphics/texture/cubemap/load_environment_map.d.ts +8 -0
- package/engine/graphics/texture/cubemap/load_environment_map.js +137 -0
- package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +3 -2
- package/engine/graphics/texture/virtual/v2/ShaderUsage.js +6 -5
- package/engine/graphics/texture/virtual/v2/prototype.js +16 -6
- package/package.json +1 -1
|
@@ -4,21 +4,6 @@ import { aabb3_project_to_2d } from "../../../../../core/geom/3d/aabb/aabb3_comp
|
|
|
4
4
|
import { BitSet } from "../../../../../core/binary/BitSet.js";
|
|
5
5
|
import { aabb3_intersects_frustum } from "../../../../../core/bvh2/aabb3/aabb3_intersects_frustum.js";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {number[]|Float32Array} bounding_box_corners
|
|
10
|
-
* @param {RefinementSpec} spec
|
|
11
|
-
* @returns {number}
|
|
12
|
-
*/
|
|
13
|
-
function compute_projected_area(bounding_box_corners, spec) {
|
|
14
|
-
// Cull by screen area
|
|
15
|
-
const normalized_screen_area = aabb3_project_to_2d(bounding_box_corners, spec.projection_matrix);
|
|
16
|
-
|
|
17
|
-
const patch_screen_area = normalized_screen_area * spec.viewport_area;
|
|
18
|
-
|
|
19
|
-
return patch_screen_area;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
7
|
export class ActivePatchList {
|
|
23
8
|
constructor() {
|
|
24
9
|
/**
|
|
@@ -38,6 +23,19 @@ export class ActivePatchList {
|
|
|
38
23
|
* @type {BitSet}
|
|
39
24
|
*/
|
|
40
25
|
this.unfolded = new BitSet();
|
|
26
|
+
|
|
27
|
+
// prevent re-allocation related thrashing
|
|
28
|
+
this.unfolded.preventShrink();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
clear() {
|
|
32
|
+
const unfolded = this.unfolded;
|
|
33
|
+
|
|
34
|
+
unfolded.reset();
|
|
35
|
+
|
|
36
|
+
ActivePatchRecord.pool_release_all(this.records);
|
|
37
|
+
|
|
38
|
+
this.records = null;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
/**
|
|
@@ -45,14 +43,15 @@ export class ActivePatchList {
|
|
|
45
43
|
* @param {MicronGeometry} geometry
|
|
46
44
|
*/
|
|
47
45
|
initializeFromGeometry(geometry) {
|
|
48
|
-
|
|
46
|
+
this.clear();
|
|
49
47
|
|
|
48
|
+
const record = ActivePatchRecord.pool_get();
|
|
49
|
+
|
|
50
|
+
record.patch = geometry.root;
|
|
50
51
|
record.link_next = null;
|
|
51
52
|
record.link_previous = null;
|
|
52
53
|
|
|
53
54
|
const unfolded = this.unfolded;
|
|
54
|
-
|
|
55
|
-
unfolded.reset();
|
|
56
55
|
unfolded.set(record.patch.id, true);
|
|
57
56
|
|
|
58
57
|
this.records = record;
|
|
@@ -61,6 +60,7 @@ export class ActivePatchList {
|
|
|
61
60
|
/**
|
|
62
61
|
*
|
|
63
62
|
* @param {ActivePatchRecord} record
|
|
63
|
+
* @returns {ActivePatchRecord}
|
|
64
64
|
*/
|
|
65
65
|
node_split(record) {
|
|
66
66
|
|
|
@@ -73,19 +73,24 @@ export class ActivePatchList {
|
|
|
73
73
|
|
|
74
74
|
const child_id = child.id;
|
|
75
75
|
|
|
76
|
-
if (unfolded.
|
|
76
|
+
if (unfolded.getAndSet(child_id)) {
|
|
77
77
|
// already unfolded, skip
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const child_record = ActivePatchRecord.
|
|
81
|
+
const child_record = ActivePatchRecord.pool_get();
|
|
82
|
+
child_record.patch = child;
|
|
82
83
|
|
|
83
84
|
this.record_insert_after(record, child_record);
|
|
84
|
-
|
|
85
|
-
unfolded.set(child_id, true);
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
this.record_remove(record);
|
|
88
|
+
|
|
89
|
+
const next = record.link_next;
|
|
90
|
+
|
|
91
|
+
ActivePatchRecord.pool_release(record);
|
|
92
|
+
|
|
93
|
+
return next;
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
/**
|
|
@@ -181,7 +186,9 @@ export class ActivePatchList {
|
|
|
181
186
|
|
|
182
187
|
const frustum_planes = spec.frustum_f32;
|
|
183
188
|
|
|
184
|
-
|
|
189
|
+
let record = this.records
|
|
190
|
+
|
|
191
|
+
for (; record !== null;) {
|
|
185
192
|
|
|
186
193
|
const node = record.patch;
|
|
187
194
|
|
|
@@ -200,6 +207,7 @@ export class ActivePatchList {
|
|
|
200
207
|
if (prev_is_visible) {
|
|
201
208
|
record.clearFlag(ActivePatchFlags.Visible);
|
|
202
209
|
}
|
|
210
|
+
record = record.link_next;
|
|
203
211
|
continue;
|
|
204
212
|
}
|
|
205
213
|
|
|
@@ -241,11 +249,11 @@ export class ActivePatchList {
|
|
|
241
249
|
|
|
242
250
|
if (screen_space_error > spec.error_threshold_normalized) {
|
|
243
251
|
// error too large, needs to be split
|
|
244
|
-
this.node_split(record);
|
|
252
|
+
record = this.node_split(record);
|
|
245
253
|
continue;
|
|
246
254
|
}
|
|
247
255
|
}
|
|
248
|
-
|
|
256
|
+
record = record.link_next;
|
|
249
257
|
|
|
250
258
|
// check if record and its sibling can be merged
|
|
251
259
|
// if (approximate_triangle_area < spec.error_threshold) {
|
|
@@ -60,8 +60,6 @@ export class ActivePatchRecord {
|
|
|
60
60
|
patch_pool_size--;
|
|
61
61
|
|
|
62
62
|
// reset record
|
|
63
|
-
r.link_next = null;
|
|
64
|
-
|
|
65
63
|
r.flags = 0;
|
|
66
64
|
|
|
67
65
|
return r;
|
|
@@ -91,6 +89,10 @@ export class ActivePatchRecord {
|
|
|
91
89
|
* @param {ActivePatchRecord} r
|
|
92
90
|
*/
|
|
93
91
|
static pool_release_all(r) {
|
|
92
|
+
if (r === null) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
94
96
|
let p = r;
|
|
95
97
|
|
|
96
98
|
for (; patch_pool_size < patch_limit;) {
|
|
@@ -50,8 +50,6 @@ import { enableEditor } from "../../../../../editor/enableEditor.js";
|
|
|
50
50
|
import EntityBuilder from "../../../../ecs/EntityBuilder.js";
|
|
51
51
|
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
52
52
|
import Mesh from "../../../ecs/mesh/Mesh.js";
|
|
53
|
-
import ViewportPosition from "../../../../ecs/gui/position/ViewportPosition.js";
|
|
54
|
-
import GUIElement from "../../../../ecs/gui/GUIElement.js";
|
|
55
53
|
import { CopyShader } from "three/examples/jsm/shaders/CopyShader.js";
|
|
56
54
|
import {
|
|
57
55
|
DoubleSide,
|
|
@@ -64,11 +62,11 @@ import {
|
|
|
64
62
|
UniformsUtils,
|
|
65
63
|
WebGLRenderTarget
|
|
66
64
|
} from "three";
|
|
67
|
-
import { buildCubeURLs } from "../../../GraphicsEngine.js";
|
|
68
65
|
import { AmbientOcclusionPostProcessEffect } from "../simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
|
|
69
66
|
import { PathDisplaySystem } from "../../../ecs/path/PathDisplaySystem.js";
|
|
70
67
|
import { MicronRenderPlugin } from "../../../micron/plugin/MicronRenderPlugin.js";
|
|
71
68
|
import { StandardFrameBuffers } from "../../../StandardFrameBuffers.js";
|
|
69
|
+
import { buildCubeURLs } from "../../../texture/cubemap/buildCubeURLs.js";
|
|
72
70
|
|
|
73
71
|
const engineHarness = new EngineHarness();
|
|
74
72
|
|
|
@@ -386,13 +384,13 @@ function main(engine) {
|
|
|
386
384
|
// .build(ecd);
|
|
387
385
|
|
|
388
386
|
// const canvasView = makeCameraClippingDebug(engine);
|
|
389
|
-
|
|
390
|
-
new EntityBuilder()
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
387
|
+
//
|
|
388
|
+
// new EntityBuilder()
|
|
389
|
+
// .add(ViewportPosition.fromJSON({
|
|
390
|
+
// offset: new Vector2(10, 10)
|
|
391
|
+
// }))
|
|
392
|
+
// .add(GUIElement.fromView(canvasView))
|
|
393
|
+
// .build(ecd);
|
|
396
394
|
|
|
397
395
|
|
|
398
396
|
}
|
|
@@ -11,15 +11,13 @@ import { compute_light_data_hash_0 } from "./cluster/compute_light_data_hash_0.j
|
|
|
11
11
|
import { read_plane_pair } from "./cluster/read_plane_pair.js";
|
|
12
12
|
import { read_frustum_planes_to_array } from "./cluster/read_frustum_planes_to_array.js";
|
|
13
13
|
import { compute_cluster_planes_from_points } from "./cluster/compute_cluster_planes_from_points.js";
|
|
14
|
-
import {
|
|
15
|
-
computeDataType,
|
|
16
|
-
computeThreeTextureInternalFormatFromDataType,
|
|
17
|
-
computeThreeTextureTypeFromDataType,
|
|
18
|
-
NumericType,
|
|
19
|
-
TextureBackedMemoryRegion
|
|
20
|
-
} from "./TextureBackedMemoryRegion.js";
|
|
14
|
+
import { TextureBackedMemoryRegion } from "./data/TextureBackedMemoryRegion.js";
|
|
21
15
|
import { assert } from "../../../../core/assert.js";
|
|
22
16
|
import { DataType2TypedArrayConstructorMapping } from "../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
17
|
+
import { NumericType } from "./data/NumericType.js";
|
|
18
|
+
import { computeDataType } from "./data/computeDataType.js";
|
|
19
|
+
import { computeThreeTextureTypeFromDataType } from "./data/computeThreeTextureTypeFromDataType.js";
|
|
20
|
+
import { computeThreeTextureInternalFormatFromDataType } from "./data/computeThreeTextureInternalFormatFromDataType.js";
|
|
23
21
|
|
|
24
22
|
const LOOKUP_CACHE_SIZE = 16384; // must be power of two
|
|
25
23
|
/**
|
|
@@ -1,36 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
RGIntegerFormat,
|
|
13
|
-
ShortType,
|
|
14
|
-
UnsignedByteType,
|
|
15
|
-
UnsignedIntType,
|
|
16
|
-
UnsignedShortType
|
|
17
|
-
} from "three";
|
|
18
|
-
import { DataType } from "../../../../core/collection/table/DataType.js";
|
|
19
|
-
import { assert } from "../../../../core/assert.js";
|
|
20
|
-
import { DataType2TypedArrayConstructorMapping } from "../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
21
|
-
import { max2 } from "../../../../core/math/max2.js";
|
|
22
|
-
import { channelCountToThreeTextureFormat } from "../../texture/channelCountToThreeTextureFormat.js";
|
|
23
|
-
import { DataTypeByteSizes } from "../../../../core/collection/table/RowFirstTableSpec.js";
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @enum {number}
|
|
28
|
-
*/
|
|
29
|
-
export const NumericType = {
|
|
30
|
-
Uint: 0,
|
|
31
|
-
Int: 1,
|
|
32
|
-
Float: 2
|
|
33
|
-
};
|
|
1
|
+
import { DataTexture, NearestFilter, RedFormat, UnsignedByteType } from "three";
|
|
2
|
+
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
3
|
+
import { assert } from "../../../../../core/assert.js";
|
|
4
|
+
import { DataType2TypedArrayConstructorMapping } from "../../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
5
|
+
import { max2 } from "../../../../../core/math/max2.js";
|
|
6
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/RowFirstTableSpec.js";
|
|
7
|
+
import { NumericType } from "./NumericType.js";
|
|
8
|
+
import { computeDataType } from "./computeDataType.js";
|
|
9
|
+
import { computeThreeTextureTypeFromDataType } from "./computeThreeTextureTypeFromDataType.js";
|
|
10
|
+
import { computeThreeTextureInternalFormatFromDataType } from "./computeThreeTextureInternalFormatFromDataType.js";
|
|
11
|
+
import { computeThreeTextureFormat } from "./computeThreeTextureFormat.js";
|
|
34
12
|
|
|
35
13
|
/**
|
|
36
14
|
* How wide a data texture is
|
|
@@ -42,163 +20,6 @@ const SHRINK_FACTOR = 0.5;
|
|
|
42
20
|
const GROW_FACTOR = 1.05;
|
|
43
21
|
|
|
44
22
|
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param {NumericType} type
|
|
48
|
-
* @param {number} precision
|
|
49
|
-
* @returns {DataType}
|
|
50
|
-
*/
|
|
51
|
-
export function computeDataType(type, precision) {
|
|
52
|
-
if (type === NumericType.Uint) {
|
|
53
|
-
if (precision <= 8) {
|
|
54
|
-
return DataType.Uint8;
|
|
55
|
-
} else if (precision <= 16) {
|
|
56
|
-
return DataType.Uint16;
|
|
57
|
-
} else if (precision <= 32) {
|
|
58
|
-
return DataType.Uint32;
|
|
59
|
-
}
|
|
60
|
-
} else if (type === NumericType.Int) {
|
|
61
|
-
if (precision <= 8) {
|
|
62
|
-
return DataType.Int8;
|
|
63
|
-
} else if (precision <= 16) {
|
|
64
|
-
return DataType.Int16;
|
|
65
|
-
} else if (precision <= 32) {
|
|
66
|
-
return DataType.Int32;
|
|
67
|
-
}
|
|
68
|
-
} else if (type === NumericType.Float) {
|
|
69
|
-
if (precision <= 32) {
|
|
70
|
-
return DataType.Float32;
|
|
71
|
-
} else if (precision <= 64) {
|
|
72
|
-
return DataType.Float64;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
throw new Error(`Unsupported numeric type(=${type}) and precision(=${precision}) combination`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
* @param {DataType} dt
|
|
82
|
-
* @returns {number}
|
|
83
|
-
*/
|
|
84
|
-
export function computeThreeTextureTypeFromDataType(dt) {
|
|
85
|
-
switch (dt) {
|
|
86
|
-
case DataType.Uint8:
|
|
87
|
-
return UnsignedByteType;
|
|
88
|
-
case DataType.Uint16:
|
|
89
|
-
return UnsignedShortType;
|
|
90
|
-
case DataType.Uint32:
|
|
91
|
-
return UnsignedIntType;
|
|
92
|
-
case DataType.Int8:
|
|
93
|
-
return ByteType;
|
|
94
|
-
case DataType.Int16:
|
|
95
|
-
return ShortType;
|
|
96
|
-
case DataType.Int32:
|
|
97
|
-
return IntType;
|
|
98
|
-
case DataType.Float16:
|
|
99
|
-
return HalfFloatType;
|
|
100
|
-
case DataType.Float32:
|
|
101
|
-
return FloatType;
|
|
102
|
-
case DataType.Float64:
|
|
103
|
-
return FloatType;
|
|
104
|
-
default:
|
|
105
|
-
throw new Error(`Unsupported data type '${dt}'`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
*
|
|
112
|
-
* @param {DataType} dt
|
|
113
|
-
* @param {number} channel_count
|
|
114
|
-
* @returns {string|THREE.PixelFormatGPU}
|
|
115
|
-
*/
|
|
116
|
-
export function computeThreeTextureInternalFormatFromDataType(dt, channel_count) {
|
|
117
|
-
let suffix = '';
|
|
118
|
-
switch (dt) {
|
|
119
|
-
case DataType.Uint8:
|
|
120
|
-
suffix = '8UI';
|
|
121
|
-
break;
|
|
122
|
-
case DataType.Uint16:
|
|
123
|
-
suffix = '16UI';
|
|
124
|
-
break;
|
|
125
|
-
case DataType.Uint32:
|
|
126
|
-
suffix = '32UI';
|
|
127
|
-
break;
|
|
128
|
-
case DataType.Int8:
|
|
129
|
-
suffix = '8I';
|
|
130
|
-
break;
|
|
131
|
-
case DataType.Int16:
|
|
132
|
-
suffix = '16I';
|
|
133
|
-
break;
|
|
134
|
-
case DataType.Int32:
|
|
135
|
-
suffix = '32I';
|
|
136
|
-
break;
|
|
137
|
-
case DataType.Float16:
|
|
138
|
-
suffix = '16F';
|
|
139
|
-
break;
|
|
140
|
-
case DataType.Float32:
|
|
141
|
-
suffix = '32F';
|
|
142
|
-
break;
|
|
143
|
-
case DataType.Float64:
|
|
144
|
-
suffix = '64F';
|
|
145
|
-
break;
|
|
146
|
-
default:
|
|
147
|
-
throw new Error(`Unsupported data type '${dt}'`);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
let prefix = '';
|
|
151
|
-
|
|
152
|
-
switch (channel_count) {
|
|
153
|
-
case 1:
|
|
154
|
-
prefix = 'R';
|
|
155
|
-
break;
|
|
156
|
-
case 2:
|
|
157
|
-
prefix = 'RG';
|
|
158
|
-
break;
|
|
159
|
-
case 3:
|
|
160
|
-
prefix = 'RGB';
|
|
161
|
-
break;
|
|
162
|
-
case 4:
|
|
163
|
-
prefix = 'RGBA';
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
throw new Error(`Unsupported channel count '${channel_count}'`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return prefix + suffix;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function channelCountToThreIntegerTextureType(channel_count) {
|
|
173
|
-
switch (channel_count) {
|
|
174
|
-
case 1:
|
|
175
|
-
return RedIntegerFormat;
|
|
176
|
-
case 2:
|
|
177
|
-
return RGIntegerFormat;
|
|
178
|
-
case 3:
|
|
179
|
-
return RGBIntegerFormat;
|
|
180
|
-
case 4:
|
|
181
|
-
return RGBAIntegerFormat;
|
|
182
|
-
default:
|
|
183
|
-
throw new Error(`Unsupported channel count '${channel_count}'`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
*
|
|
189
|
-
* @param {NumericType} type
|
|
190
|
-
* @param {number} channel_count
|
|
191
|
-
*/
|
|
192
|
-
function computeThreeTextureFormat(type, channel_count) {
|
|
193
|
-
if (type === NumericType.Uint || type === NumericType.Int) {
|
|
194
|
-
return channelCountToThreIntegerTextureType(channel_count);
|
|
195
|
-
} else if (type === NumericType.Float) {
|
|
196
|
-
return channelCountToThreeTextureFormat(channel_count);
|
|
197
|
-
} else {
|
|
198
|
-
throw new Error(`Unsupported numeric type '${type}'`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
23
|
export class TextureBackedMemoryRegion {
|
|
203
24
|
|
|
204
25
|
constructor() {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RedIntegerFormat, RGBAIntegerFormat, RGBIntegerFormat, RGIntegerFormat } from "three";
|
|
2
|
+
|
|
3
|
+
export function channelCountToThreIntegerTextureType(channel_count) {
|
|
4
|
+
switch (channel_count) {
|
|
5
|
+
case 1:
|
|
6
|
+
return RedIntegerFormat;
|
|
7
|
+
case 2:
|
|
8
|
+
return RGIntegerFormat;
|
|
9
|
+
case 3:
|
|
10
|
+
return RGBIntegerFormat;
|
|
11
|
+
case 4:
|
|
12
|
+
return RGBAIntegerFormat;
|
|
13
|
+
default:
|
|
14
|
+
throw new Error(`Unsupported channel count '${channel_count}'`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { NumericType } from "./NumericType.js";
|
|
2
|
+
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {NumericType} type
|
|
7
|
+
* @param {number} precision
|
|
8
|
+
* @returns {DataType}
|
|
9
|
+
*/
|
|
10
|
+
export function computeDataType(type, precision) {
|
|
11
|
+
if (type === NumericType.Uint) {
|
|
12
|
+
if (precision <= 8) {
|
|
13
|
+
return DataType.Uint8;
|
|
14
|
+
} else if (precision <= 16) {
|
|
15
|
+
return DataType.Uint16;
|
|
16
|
+
} else if (precision <= 32) {
|
|
17
|
+
return DataType.Uint32;
|
|
18
|
+
}
|
|
19
|
+
} else if (type === NumericType.Int) {
|
|
20
|
+
if (precision <= 8) {
|
|
21
|
+
return DataType.Int8;
|
|
22
|
+
} else if (precision <= 16) {
|
|
23
|
+
return DataType.Int16;
|
|
24
|
+
} else if (precision <= 32) {
|
|
25
|
+
return DataType.Int32;
|
|
26
|
+
}
|
|
27
|
+
} else if (type === NumericType.Float) {
|
|
28
|
+
if (precision <= 32) {
|
|
29
|
+
return DataType.Float32;
|
|
30
|
+
} else if (precision <= 64) {
|
|
31
|
+
return DataType.Float64;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
throw new Error(`Unsupported numeric type(=${type}) and precision(=${precision}) combination`);
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NumericType } from "./NumericType.js";
|
|
2
|
+
import { channelCountToThreIntegerTextureType } from "./channelCountToThreIntegerTextureType.js";
|
|
3
|
+
import { channelCountToThreeTextureFormat } from "../../../texture/channelCountToThreeTextureFormat.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {NumericType} type
|
|
8
|
+
* @param {number} channel_count
|
|
9
|
+
*/
|
|
10
|
+
export function computeThreeTextureFormat(type, channel_count) {
|
|
11
|
+
if (type === NumericType.Uint || type === NumericType.Int) {
|
|
12
|
+
return channelCountToThreIntegerTextureType(channel_count);
|
|
13
|
+
} else if (type === NumericType.Float) {
|
|
14
|
+
return channelCountToThreeTextureFormat(channel_count);
|
|
15
|
+
} else {
|
|
16
|
+
throw new Error(`Unsupported numeric type '${type}'`);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {DataType} dt
|
|
6
|
+
* @param {number} channel_count
|
|
7
|
+
* @returns {string|THREE.PixelFormatGPU}
|
|
8
|
+
*/
|
|
9
|
+
export function computeThreeTextureInternalFormatFromDataType(dt, channel_count) {
|
|
10
|
+
let suffix = '';
|
|
11
|
+
switch (dt) {
|
|
12
|
+
case DataType.Uint8:
|
|
13
|
+
suffix = '8UI';
|
|
14
|
+
break;
|
|
15
|
+
case DataType.Uint16:
|
|
16
|
+
suffix = '16UI';
|
|
17
|
+
break;
|
|
18
|
+
case DataType.Uint32:
|
|
19
|
+
suffix = '32UI';
|
|
20
|
+
break;
|
|
21
|
+
case DataType.Int8:
|
|
22
|
+
suffix = '8I';
|
|
23
|
+
break;
|
|
24
|
+
case DataType.Int16:
|
|
25
|
+
suffix = '16I';
|
|
26
|
+
break;
|
|
27
|
+
case DataType.Int32:
|
|
28
|
+
suffix = '32I';
|
|
29
|
+
break;
|
|
30
|
+
case DataType.Float16:
|
|
31
|
+
suffix = '16F';
|
|
32
|
+
break;
|
|
33
|
+
case DataType.Float32:
|
|
34
|
+
suffix = '32F';
|
|
35
|
+
break;
|
|
36
|
+
case DataType.Float64:
|
|
37
|
+
suffix = '64F';
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
throw new Error(`Unsupported data type '${dt}'`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let prefix = '';
|
|
44
|
+
|
|
45
|
+
switch (channel_count) {
|
|
46
|
+
case 1:
|
|
47
|
+
prefix = 'R';
|
|
48
|
+
break;
|
|
49
|
+
case 2:
|
|
50
|
+
prefix = 'RG';
|
|
51
|
+
break;
|
|
52
|
+
case 3:
|
|
53
|
+
prefix = 'RGB';
|
|
54
|
+
break;
|
|
55
|
+
case 4:
|
|
56
|
+
prefix = 'RGBA';
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported channel count '${channel_count}'`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return prefix + suffix;
|
|
63
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
2
|
+
import {
|
|
3
|
+
ByteType,
|
|
4
|
+
FloatType,
|
|
5
|
+
HalfFloatType,
|
|
6
|
+
IntType,
|
|
7
|
+
ShortType,
|
|
8
|
+
UnsignedByteType,
|
|
9
|
+
UnsignedIntType,
|
|
10
|
+
UnsignedShortType
|
|
11
|
+
} from "three";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {DataType} dt
|
|
16
|
+
* @returns {number}
|
|
17
|
+
*/
|
|
18
|
+
export function computeThreeTextureTypeFromDataType(dt) {
|
|
19
|
+
switch (dt) {
|
|
20
|
+
case DataType.Uint8:
|
|
21
|
+
return UnsignedByteType;
|
|
22
|
+
case DataType.Uint16:
|
|
23
|
+
return UnsignedShortType;
|
|
24
|
+
case DataType.Uint32:
|
|
25
|
+
return UnsignedIntType;
|
|
26
|
+
case DataType.Int8:
|
|
27
|
+
return ByteType;
|
|
28
|
+
case DataType.Int16:
|
|
29
|
+
return ShortType;
|
|
30
|
+
case DataType.Int32:
|
|
31
|
+
return IntType;
|
|
32
|
+
case DataType.Float16:
|
|
33
|
+
return HalfFloatType;
|
|
34
|
+
case DataType.Float32:
|
|
35
|
+
return FloatType;
|
|
36
|
+
case DataType.Float64:
|
|
37
|
+
return FloatType;
|
|
38
|
+
default:
|
|
39
|
+
throw new Error(`Unsupported data type '${dt}'`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -45,7 +45,6 @@ import { SerializationMetadataSystem } from "../../../../ecs/systems/Serializati
|
|
|
45
45
|
import { InverseKinematicsSystem } from "../../../../ecs/animation/InverseKinematicsSystem.js";
|
|
46
46
|
import { PathDisplaySystem } from "../../../ecs/path/PathDisplaySystem.js";
|
|
47
47
|
import { Line, LineBasicMaterial, MeshStandardMaterial, TorusKnotBufferGeometry } from "three";
|
|
48
|
-
import { buildCubeURLs } from "../../../GraphicsEngine.js";
|
|
49
48
|
import RenderSystem from "../../../../ecs/systems/RenderSystem.js";
|
|
50
49
|
import { makeEngineOptionsModel } from "../../../../../../model/game/options/makeEngineOptionsModel.js";
|
|
51
50
|
import { enableEditor } from "../../../../../editor/enableEditor.js";
|
|
@@ -77,6 +76,7 @@ import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
|
77
76
|
import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
|
|
78
77
|
import { ImageRGBADataLoader } from "../../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
79
78
|
import { MicronRenderPlugin } from "../../../micron/plugin/MicronRenderPlugin.js";
|
|
79
|
+
import { buildCubeURLs } from "../../../texture/cubemap/buildCubeURLs.js";
|
|
80
80
|
|
|
81
81
|
const engineHarness = new EngineHarness();
|
|
82
82
|
|