@woosh/meep-engine 2.33.1 → 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 +18 -0
- package/core/bvh2/aabb3/aabb3_intersects_frustum.js +38 -0
- 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 +11 -10
- 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/core/geom/3d/plane/plane3_lerp.js +2 -2
- package/core/geom/3d/topology/TopoTriangle.js +2 -2
- package/core/geom/AABB2.d.ts +2 -0
- package/core/geom/Matrix4.js +4 -4
- package/core/geom/Vector3.js +5 -5
- package/core/model/reactive/model/terminal/ReactiveReference.js +7 -1
- package/engine/asset/loaders/GLTFAssetLoader.js +3 -3
- package/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +11 -1
- package/engine/asset/loaders/material/TextureAttachment.js +12 -1
- package/engine/asset/loaders/material/computeTextureEquality.js +1 -1
- package/engine/asset/loaders/material/computeTextureHash.js +16 -14
- package/engine/asset/loaders/material/traverseMaterialTextures.js +2 -2
- package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +2 -2
- package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +4 -4
- package/engine/graphics/GraphicsEngine.d.ts +2 -2
- package/engine/graphics/GraphicsEngine.js +20 -62
- 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/geometry/bvh/buffered/BVHGeometryRaycaster.js +2 -2
- package/engine/graphics/material/optimization/MaterialOptimizationContext.js +598 -0
- package/engine/graphics/micron/build/PatchRepresentation.js +4 -43
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +3 -70
- package/engine/graphics/micron/build/compute_buffer_geometry_byte_size.js +16 -0
- package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +1 -1
- package/engine/graphics/micron/format/MicronGeometryPatch.js +9 -5
- package/engine/graphics/micron/prototypeVirtualGeometry.js +19 -12
- package/engine/graphics/micron/render/RefinementSpec.js +104 -33
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +12 -21
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +2 -4
- package/engine/graphics/micron/render/instanced/PatchDataTextures.js +1 -0
- package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +1 -29
- package/engine/graphics/micron/render/refinement/ActivePatchList.js +41 -138
- package/engine/graphics/micron/render/refinement/ActivePatchRecord.js +4 -2
- package/engine/graphics/micron/render/refinement/is_patch_facing_back.js +43 -0
- package/engine/graphics/micron/render/refinement/is_patch_visible.js +37 -0
- package/engine/graphics/micron/util/unit_hemioct.spec.js +2 -2
- package/engine/graphics/render/buffer/buffers/NormalFrameBuffer.js +12 -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/utils/ThreeBypassRenderer.js +1 -3
- package/engine/graphics/render/visibility/VisibilityComputer.js +11 -0
- 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/atlas/TextureAtlas.js +1 -1
- 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 +8 -4
- 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
- package/view/elements/progress/segmented/SegmentedResourceBarView.js +50 -15
|
@@ -1,102 +1,8 @@
|
|
|
1
1
|
import { ActivePatchRecord } from "./ActivePatchRecord.js";
|
|
2
2
|
import { ActivePatchFlags } from "./ActivePatchFlags.js";
|
|
3
|
-
import { PI_HALF } from "../../../../../core/math/MathUtils.js";
|
|
4
|
-
import { v3_angleBetween } from "../../../../../core/geom/Vector3.js";
|
|
5
3
|
import { aabb3_project_to_2d } from "../../../../../core/geom/3d/aabb/aabb3_compute_projected_area.js";
|
|
6
|
-
import AABB2 from "../../../../../core/geom/AABB2.js";
|
|
7
|
-
import { approximateTriangleArea } from "../approximateTriangleArea.js";
|
|
8
4
|
import { BitSet } from "../../../../../core/binary/BitSet.js";
|
|
9
|
-
|
|
10
|
-
const scratch_aabb2 = new AABB2();
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {RefinementSpec} refinement_spec
|
|
15
|
-
* @param {MicronGeometryPatch} patch
|
|
16
|
-
* @returns {boolean}
|
|
17
|
-
*/
|
|
18
|
-
function is_patch_facing_back(refinement_spec, patch) {
|
|
19
|
-
|
|
20
|
-
const normal_cone = patch.normal_cone;
|
|
21
|
-
const normal_cone_angle = normal_cone.angle;
|
|
22
|
-
|
|
23
|
-
// Do normal cone check against view angle
|
|
24
|
-
if (normal_cone_angle < PI_HALF) {
|
|
25
|
-
// compute view direction
|
|
26
|
-
// TODO position might be way off from the surface center, as well as patch might curve a lot more than expected, need to account for that
|
|
27
|
-
|
|
28
|
-
const bounds_center_x = patch.bounding_sphere[0];
|
|
29
|
-
const bounds_center_y = patch.bounding_sphere[1];
|
|
30
|
-
const bounds_center_z = patch.bounding_sphere[2];
|
|
31
|
-
|
|
32
|
-
const view_direction_x = refinement_spec.view_position[0] - bounds_center_x;
|
|
33
|
-
const view_direction_y = refinement_spec.view_position[1] - bounds_center_y;
|
|
34
|
-
const view_direction_z = refinement_spec.view_position[2] - bounds_center_z;
|
|
35
|
-
|
|
36
|
-
// compute view angle of the bounding sphere
|
|
37
|
-
const normal_cone_direction = normal_cone.direction;
|
|
38
|
-
|
|
39
|
-
const angle = v3_angleBetween(
|
|
40
|
-
view_direction_x, view_direction_y, view_direction_z,
|
|
41
|
-
normal_cone_direction.x, normal_cone_direction.y, normal_cone_direction.z
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
if (angle > normal_cone_angle + PI_HALF) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* @param {RefinementSpec} refinement_spec
|
|
56
|
-
* @param {MicronGeometryPatch} node
|
|
57
|
-
* @returns {boolean}
|
|
58
|
-
*/
|
|
59
|
-
function is_patch_visible(refinement_spec, node) {
|
|
60
|
-
|
|
61
|
-
// check if node is in view frustum
|
|
62
|
-
const bounding_box = node.bounding_box;
|
|
63
|
-
const in_view_frustum = bounding_box.intersectFrustum(refinement_spec.frustum);
|
|
64
|
-
|
|
65
|
-
if (!in_view_frustum) {
|
|
66
|
-
// outside of view frustum, cull
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// compute projected bounds of the patch
|
|
72
|
-
aabb3_project_to_2d(scratch_aabb2, bounding_box, refinement_spec.projection_matrix);
|
|
73
|
-
|
|
74
|
-
// Cull by screen area
|
|
75
|
-
const normalized_screen_area = scratch_aabb2.computeArea();
|
|
76
|
-
const patch_screen_area = normalized_screen_area * refinement_spec.viewport_area;
|
|
77
|
-
|
|
78
|
-
if (patch_screen_area < refinement_spec.error_threshold) {
|
|
79
|
-
// the whole patch is too small, cull
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
*
|
|
88
|
-
* @param {AABB3} bounding_box
|
|
89
|
-
* @param {RefinementSpec} spec
|
|
90
|
-
* @returns {number}
|
|
91
|
-
*/
|
|
92
|
-
function compute_projected_area(bounding_box, spec) {
|
|
93
|
-
aabb3_project_to_2d(scratch_aabb2, bounding_box, spec.projection_matrix);
|
|
94
|
-
|
|
95
|
-
// Cull by screen area
|
|
96
|
-
const normalized_screen_area = scratch_aabb2.computeArea();
|
|
97
|
-
const patch_screen_area = normalized_screen_area * spec.viewport_area;
|
|
98
|
-
return patch_screen_area;
|
|
99
|
-
}
|
|
5
|
+
import { aabb3_intersects_frustum } from "../../../../../core/bvh2/aabb3/aabb3_intersects_frustum.js";
|
|
100
6
|
|
|
101
7
|
export class ActivePatchList {
|
|
102
8
|
constructor() {
|
|
@@ -117,6 +23,19 @@ export class ActivePatchList {
|
|
|
117
23
|
* @type {BitSet}
|
|
118
24
|
*/
|
|
119
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;
|
|
120
39
|
}
|
|
121
40
|
|
|
122
41
|
/**
|
|
@@ -124,13 +43,16 @@ export class ActivePatchList {
|
|
|
124
43
|
* @param {MicronGeometry} geometry
|
|
125
44
|
*/
|
|
126
45
|
initializeFromGeometry(geometry) {
|
|
127
|
-
|
|
46
|
+
this.clear();
|
|
47
|
+
|
|
48
|
+
const record = ActivePatchRecord.pool_get();
|
|
128
49
|
|
|
50
|
+
record.patch = geometry.root;
|
|
129
51
|
record.link_next = null;
|
|
130
52
|
record.link_previous = null;
|
|
131
53
|
|
|
132
|
-
this.unfolded
|
|
133
|
-
|
|
54
|
+
const unfolded = this.unfolded;
|
|
55
|
+
unfolded.set(record.patch.id, true);
|
|
134
56
|
|
|
135
57
|
this.records = record;
|
|
136
58
|
}
|
|
@@ -138,6 +60,7 @@ export class ActivePatchList {
|
|
|
138
60
|
/**
|
|
139
61
|
*
|
|
140
62
|
* @param {ActivePatchRecord} record
|
|
63
|
+
* @returns {ActivePatchRecord}
|
|
141
64
|
*/
|
|
142
65
|
node_split(record) {
|
|
143
66
|
|
|
@@ -150,19 +73,24 @@ export class ActivePatchList {
|
|
|
150
73
|
|
|
151
74
|
const child_id = child.id;
|
|
152
75
|
|
|
153
|
-
if (unfolded.
|
|
76
|
+
if (unfolded.getAndSet(child_id)) {
|
|
154
77
|
// already unfolded, skip
|
|
155
78
|
continue;
|
|
156
79
|
}
|
|
157
80
|
|
|
158
|
-
const child_record = ActivePatchRecord.
|
|
81
|
+
const child_record = ActivePatchRecord.pool_get();
|
|
82
|
+
child_record.patch = child;
|
|
159
83
|
|
|
160
84
|
this.record_insert_after(record, child_record);
|
|
161
|
-
|
|
162
|
-
unfolded.set(child_id, true);
|
|
163
85
|
}
|
|
164
86
|
|
|
165
87
|
this.record_remove(record);
|
|
88
|
+
|
|
89
|
+
const next = record.link_next;
|
|
90
|
+
|
|
91
|
+
ActivePatchRecord.pool_release(record);
|
|
92
|
+
|
|
93
|
+
return next;
|
|
166
94
|
}
|
|
167
95
|
|
|
168
96
|
/**
|
|
@@ -226,36 +154,6 @@ export class ActivePatchList {
|
|
|
226
154
|
this.record_remove(b);
|
|
227
155
|
}
|
|
228
156
|
|
|
229
|
-
/**
|
|
230
|
-
*
|
|
231
|
-
* @param {ActivePatchRecord} record
|
|
232
|
-
* @param {RefinementSpec} spec
|
|
233
|
-
*/
|
|
234
|
-
node_try_merge(record, spec) {
|
|
235
|
-
const next = record.link_next;
|
|
236
|
-
if (next === null) {
|
|
237
|
-
// no next record
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return;
|
|
242
|
-
|
|
243
|
-
const parent = record.patch.parent;
|
|
244
|
-
|
|
245
|
-
if (parent !== next.patch.parent) {
|
|
246
|
-
// not a sibling
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const patch_screen_area = compute_projected_area(parent.bounding_box, spec);
|
|
251
|
-
|
|
252
|
-
const approximate_triangle_area = patch_screen_area * approximateTriangleArea(parent);
|
|
253
|
-
|
|
254
|
-
if (approximate_triangle_area <= spec.error_threshold) {
|
|
255
|
-
this.node_merge(record, next);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
}
|
|
259
157
|
|
|
260
158
|
/**
|
|
261
159
|
* Populate with LOD-X of a given geometry
|
|
@@ -286,7 +184,11 @@ export class ActivePatchList {
|
|
|
286
184
|
*/
|
|
287
185
|
refine(spec) {
|
|
288
186
|
|
|
289
|
-
|
|
187
|
+
const frustum_planes = spec.frustum_f32;
|
|
188
|
+
|
|
189
|
+
let record = this.records
|
|
190
|
+
|
|
191
|
+
for (; record !== null;) {
|
|
290
192
|
|
|
291
193
|
const node = record.patch;
|
|
292
194
|
|
|
@@ -298,13 +200,14 @@ export class ActivePatchList {
|
|
|
298
200
|
NOTE: following suggestion in "FastMesh: Efficient View-dependent Meshing" by Renato Pajarola et al, we can do a more coarse frustum test approximating frustum as a cone initially
|
|
299
201
|
*/
|
|
300
202
|
const bounding_box = node.bounding_box;
|
|
301
|
-
const in_view_frustum = bounding_box
|
|
203
|
+
const in_view_frustum = aabb3_intersects_frustum(bounding_box, frustum_planes);
|
|
302
204
|
|
|
303
205
|
if (!in_view_frustum) {
|
|
304
206
|
// outside of view frustum, cull
|
|
305
207
|
if (prev_is_visible) {
|
|
306
208
|
record.clearFlag(ActivePatchFlags.Visible);
|
|
307
209
|
}
|
|
210
|
+
record = record.link_next;
|
|
308
211
|
continue;
|
|
309
212
|
}
|
|
310
213
|
|
|
@@ -340,17 +243,17 @@ export class ActivePatchList {
|
|
|
340
243
|
// not the lowest level of LOD, see if subdivision might be necessary
|
|
341
244
|
|
|
342
245
|
// compute average triangle area
|
|
343
|
-
const group_screen_area =
|
|
246
|
+
const group_screen_area = aabb3_project_to_2d(node.group_bounding_box_corners, spec.projection_matrix);
|
|
344
247
|
const screen_space_error = node.group_error * group_screen_area;
|
|
345
248
|
|
|
346
249
|
|
|
347
|
-
if (screen_space_error > spec.
|
|
250
|
+
if (screen_space_error > spec.error_threshold_normalized) {
|
|
348
251
|
// error too large, needs to be split
|
|
349
|
-
this.node_split(record);
|
|
252
|
+
record = this.node_split(record);
|
|
350
253
|
continue;
|
|
351
254
|
}
|
|
352
255
|
}
|
|
353
|
-
|
|
256
|
+
record = record.link_next;
|
|
354
257
|
|
|
355
258
|
// check if record and its sibling can be merged
|
|
356
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;) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PI_HALF } from "../../../../../core/math/MathUtils.js";
|
|
2
|
+
import { v3_angleBetween } from "../../../../../core/geom/Vector3.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {RefinementSpec} refinement_spec
|
|
7
|
+
* @param {MicronGeometryPatch} patch
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function is_patch_facing_back(refinement_spec, patch) {
|
|
11
|
+
|
|
12
|
+
const normal_cone = patch.normal_cone;
|
|
13
|
+
const normal_cone_angle = normal_cone.angle;
|
|
14
|
+
|
|
15
|
+
// Do normal cone check against view angle
|
|
16
|
+
if (normal_cone_angle < PI_HALF) {
|
|
17
|
+
// compute view direction
|
|
18
|
+
// TODO position might be way off from the surface center, as well as patch might curve a lot more than expected, need to account for that
|
|
19
|
+
|
|
20
|
+
const bounds_center_x = patch.bounding_sphere[0];
|
|
21
|
+
const bounds_center_y = patch.bounding_sphere[1];
|
|
22
|
+
const bounds_center_z = patch.bounding_sphere[2];
|
|
23
|
+
|
|
24
|
+
const view_direction_x = refinement_spec.view_position[0] - bounds_center_x;
|
|
25
|
+
const view_direction_y = refinement_spec.view_position[1] - bounds_center_y;
|
|
26
|
+
const view_direction_z = refinement_spec.view_position[2] - bounds_center_z;
|
|
27
|
+
|
|
28
|
+
// compute view angle of the bounding sphere
|
|
29
|
+
const normal_cone_direction = normal_cone.direction;
|
|
30
|
+
|
|
31
|
+
const angle = v3_angleBetween(
|
|
32
|
+
view_direction_x, view_direction_y, view_direction_z,
|
|
33
|
+
normal_cone_direction.x, normal_cone_direction.y, normal_cone_direction.z
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (angle > normal_cone_angle + PI_HALF) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import AABB2 from "../../../../../core/geom/AABB2.js";
|
|
2
|
+
import { aabb3_project_to_2d } from "../../../../../core/geom/3d/aabb/aabb3_compute_projected_area.js";
|
|
3
|
+
|
|
4
|
+
const scratch_aabb2 = new AABB2();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {RefinementSpec} refinement_spec
|
|
9
|
+
* @param {MicronGeometryPatch} node
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
*/
|
|
12
|
+
function is_patch_visible(refinement_spec, node) {
|
|
13
|
+
|
|
14
|
+
// check if node is in view frustum
|
|
15
|
+
const bounding_box = node.bounding_box;
|
|
16
|
+
const in_view_frustum = bounding_box.intersectFrustum(refinement_spec.frustum);
|
|
17
|
+
|
|
18
|
+
if (!in_view_frustum) {
|
|
19
|
+
// outside of view frustum, cull
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// compute projected bounds of the patch
|
|
25
|
+
aabb3_project_to_2d(scratch_aabb2, bounding_box, refinement_spec.projection_matrix);
|
|
26
|
+
|
|
27
|
+
// Cull by screen area
|
|
28
|
+
const normalized_screen_area = scratch_aabb2.computeArea();
|
|
29
|
+
const patch_screen_area = normalized_screen_area * refinement_spec.viewport_area;
|
|
30
|
+
|
|
31
|
+
if (patch_screen_area < refinement_spec.error_threshold) {
|
|
32
|
+
// the whole patch is too small, cull
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decode_hemioct_to_unit, encode_unit_to_hemioct } from "./encode_unit3_hemioct.js";
|
|
2
|
-
import {
|
|
2
|
+
import { v3_length } from "../../../../core/geom/Vector3.js";
|
|
3
3
|
|
|
4
4
|
test('encode-decode', () => {
|
|
5
5
|
const v0 = [];
|
|
@@ -7,7 +7,7 @@ test('encode-decode', () => {
|
|
|
7
7
|
|
|
8
8
|
function validate(x, y, z) {
|
|
9
9
|
// normalize input
|
|
10
|
-
const l = 1 /
|
|
10
|
+
const l = 1 / v3_length(x, y, z);
|
|
11
11
|
|
|
12
12
|
const _x = x * l;
|
|
13
13
|
const _y = y * l;
|
|
@@ -52,11 +52,15 @@ export class NormalFrameBuffer extends FrameBuffer {
|
|
|
52
52
|
this.__material_skinned.side = DoubleSide;
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
const scene = new Scene();
|
|
55
56
|
/**
|
|
56
57
|
* @type {Scene}
|
|
57
58
|
* @private
|
|
58
59
|
*/
|
|
59
|
-
this.__scene =
|
|
60
|
+
this.__scene = scene;
|
|
61
|
+
scene.autoUpdate = false;
|
|
62
|
+
scene.matrixAutoUpdate = false;
|
|
63
|
+
scene.matrixWorldNeedsUpdate = false;
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
|
|
@@ -90,7 +94,13 @@ export class NormalFrameBuffer extends FrameBuffer {
|
|
|
90
94
|
|
|
91
95
|
if (source_material !== undefined) {
|
|
92
96
|
// assign normal map and color map
|
|
93
|
-
|
|
97
|
+
|
|
98
|
+
if (source_material.alphaTest > 0) {
|
|
99
|
+
target_material.map = source_material.map;
|
|
100
|
+
} else {
|
|
101
|
+
target_material.map = null;
|
|
102
|
+
}
|
|
103
|
+
|
|
94
104
|
target_material.normalMap = source_material.normalMap;
|
|
95
105
|
}
|
|
96
106
|
}
|
|
@@ -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
|
/**
|