@woosh/meep-engine 2.75.2 → 2.75.4
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/build/meep.cjs +56 -60
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +56 -60
- package/package.json +1 -1
- package/src/core/geom/3d/ray/ray_computeNearestPointToPoint.js +7 -1
- package/src/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +19 -39
- package/src/core/geom/3d/v3_compute_triangle_normal.js +1 -1
- package/src/core/geom/Quaternion.js +0 -59
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +2 -1
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshHighlightSystem.js +7 -1
- package/src/engine/graphics/geometry/VertexDataSpec.d.ts +10 -0
- package/src/engine/graphics/geometry/VertexDataSpec.js +20 -21
- package/src/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +41 -10
- package/src/engine/graphics/texture/formatToChannelCount.js +2 -1
- package/src/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +2 -2
- package/src/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +20 -19
- package/src/engine/graphics/texture/virtual/v2/NOTES.md +93 -1
- package/src/engine/graphics/texture/virtual/v2/VirtualTextureMaterial.js +193 -0
- package/src/engine/graphics/texture/virtual/v2/VirtualTextureMemoryMapping.js +203 -0
- package/src/engine/graphics/texture/virtual/v2/{PageTexture.js → VirtualTexturePage.js} +151 -22
- package/src/engine/graphics/texture/virtual/v2/VirtualTextureTileLoader.js +10 -1
- package/src/engine/graphics/texture/virtual/v2/VirtualTextureUsage.js +43 -10
- package/src/engine/graphics/texture/virtual/v2/VirtualTextureUsageShader.js +3 -3
- package/src/engine/graphics/texture/virtual/v2/VirtualTextureUsageUpdater.js +39 -11
- package/src/engine/graphics/texture/virtual/v2/debug/ResidencyDebugView.js +20 -5
- package/src/engine/graphics/texture/virtual/v2/prototype.js +148 -62
- package/src/engine/graphics/texture/virtual/v2/tile/VirtualTextureTile.js +4 -0
- package/src/core/bvh2/sah/surfaceAreaHeuristic.js +0 -15
- package/src/core/bvh2/sah/surfaceAreaHeuristicFull.js +0 -14
- package/src/core/geom/3d/aabb/computeBoundingBoxFromVertexData.js +0 -12
- package/src/core/geom/3d/frustum/array_normalize_plane.js +0 -25
- package/src/core/geom/3d/plane/lerp_planes_to_array.js +0 -53
- package/src/core/geom/3d/plane/planeRayIntersection.js +0 -14
- package/src/core/geom/3d/voxel/DenseBitVolume3D.js +0 -87
- package/src/core/geom/3d/voxel/buildVolumeFromProjectedGeometry.js +0 -23
- package/src/engine/graphics/texture/virtual/v2/ResidentTileTexture.js +0 -46
- /package/src/core/math/{bessel_i0.spec.js → bessel_j0.spec.js} +0 -0
package/build/meep.module.js
CHANGED
|
@@ -3904,65 +3904,6 @@ let Quaternion$1 = class Quaternion {
|
|
|
3904
3904
|
result.set(psi, theta, phi);
|
|
3905
3905
|
}
|
|
3906
3906
|
|
|
3907
|
-
/**
|
|
3908
|
-
*
|
|
3909
|
-
* @param {Matrix4} m
|
|
3910
|
-
*/
|
|
3911
|
-
threeSetRotationMatrix(m) {
|
|
3912
|
-
throw new Error('Deprecated');
|
|
3913
|
-
}
|
|
3914
|
-
|
|
3915
|
-
/**
|
|
3916
|
-
* Read out rotation into a matrix
|
|
3917
|
-
* @param {Array<Number>} elements
|
|
3918
|
-
*/
|
|
3919
|
-
setRotationMatrix(elements) {
|
|
3920
|
-
const x = this.x;
|
|
3921
|
-
const y = this.y;
|
|
3922
|
-
const z = this.z;
|
|
3923
|
-
const w = this.w;
|
|
3924
|
-
|
|
3925
|
-
const x2 = x + x;
|
|
3926
|
-
const y2 = y + y;
|
|
3927
|
-
const z2 = z + z;
|
|
3928
|
-
|
|
3929
|
-
const xx = x * x2;
|
|
3930
|
-
const xy = x * y2;
|
|
3931
|
-
const xz = x * z2;
|
|
3932
|
-
|
|
3933
|
-
const yy = y * y2;
|
|
3934
|
-
const yz = y * z2;
|
|
3935
|
-
const zz = z * z2;
|
|
3936
|
-
|
|
3937
|
-
const wx = w * x2;
|
|
3938
|
-
const wy = w * y2;
|
|
3939
|
-
const wz = w * z2;
|
|
3940
|
-
|
|
3941
|
-
// set 3x3 rotation matrix
|
|
3942
|
-
elements[0] = 1 - (yy + zz);
|
|
3943
|
-
elements[4] = xy - wz;
|
|
3944
|
-
elements[8] = xz + wy;
|
|
3945
|
-
|
|
3946
|
-
elements[1] = xy + wz;
|
|
3947
|
-
elements[5] = 1 - (xx + zz);
|
|
3948
|
-
elements[9] = yz - wx;
|
|
3949
|
-
|
|
3950
|
-
elements[2] = xz - wy;
|
|
3951
|
-
elements[6] = yz + wx;
|
|
3952
|
-
elements[10] = 1 - (xx + yy);
|
|
3953
|
-
|
|
3954
|
-
// last column
|
|
3955
|
-
elements[3] = 0;
|
|
3956
|
-
elements[7] = 0;
|
|
3957
|
-
elements[11] = 0;
|
|
3958
|
-
|
|
3959
|
-
// bottom row
|
|
3960
|
-
elements[12] = 0;
|
|
3961
|
-
elements[13] = 0;
|
|
3962
|
-
elements[14] = 0;
|
|
3963
|
-
elements[15] = 1;
|
|
3964
|
-
}
|
|
3965
|
-
|
|
3966
3907
|
/**
|
|
3967
3908
|
* XYZ order
|
|
3968
3909
|
* @source: https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine
|
|
@@ -69482,6 +69423,61 @@ class CodecWithFallback extends Codec {
|
|
|
69482
69423
|
}
|
|
69483
69424
|
}
|
|
69484
69425
|
|
|
69426
|
+
/**
|
|
69427
|
+
*
|
|
69428
|
+
* @param {Image|ImageBitmap|HTMLImageElement} img
|
|
69429
|
+
* @returns {Uint8Array}
|
|
69430
|
+
*/
|
|
69431
|
+
function decode(img) {
|
|
69432
|
+
const imgWidth = img.width;
|
|
69433
|
+
const imgHeight = img.height;
|
|
69434
|
+
|
|
69435
|
+
//
|
|
69436
|
+
const canvas = document.createElement('canvas');
|
|
69437
|
+
|
|
69438
|
+
canvas.width = imgWidth;
|
|
69439
|
+
canvas.height = imgHeight;
|
|
69440
|
+
|
|
69441
|
+
const context = canvas.getContext('2d');
|
|
69442
|
+
|
|
69443
|
+
context.drawImage(img, 0, 0, imgWidth, imgHeight);
|
|
69444
|
+
|
|
69445
|
+
const imgd = context.getImageData(0, 0, imgWidth, imgHeight);
|
|
69446
|
+
|
|
69447
|
+
return imgd.data;
|
|
69448
|
+
}
|
|
69449
|
+
|
|
69450
|
+
class NativeImageDecoder extends Codec {
|
|
69451
|
+
async decode(data) {
|
|
69452
|
+
const image = new Image();
|
|
69453
|
+
|
|
69454
|
+
// convert binary data to image URL that we can load
|
|
69455
|
+
const blob = new Blob([data]);
|
|
69456
|
+
const url = URL.createObjectURL(blob);
|
|
69457
|
+
|
|
69458
|
+
image.src = url;
|
|
69459
|
+
|
|
69460
|
+
// give browser a chance to decode image in async
|
|
69461
|
+
await image.decode();
|
|
69462
|
+
|
|
69463
|
+
const rgba_data = decode(image);
|
|
69464
|
+
|
|
69465
|
+
const width = image.width;
|
|
69466
|
+
const height = image.height;
|
|
69467
|
+
|
|
69468
|
+
// release resources
|
|
69469
|
+
URL.revokeObjectURL(url);
|
|
69470
|
+
|
|
69471
|
+
return {
|
|
69472
|
+
data: rgba_data,
|
|
69473
|
+
width: width,
|
|
69474
|
+
height: height,
|
|
69475
|
+
itemSize: 4,
|
|
69476
|
+
bitDepth: 8
|
|
69477
|
+
};
|
|
69478
|
+
}
|
|
69479
|
+
}
|
|
69480
|
+
|
|
69485
69481
|
class OnDemandWorkerManager {
|
|
69486
69482
|
|
|
69487
69483
|
/**
|
|
@@ -69697,7 +69693,7 @@ class ImageRGBADataLoader extends AssetLoader {
|
|
|
69697
69693
|
|
|
69698
69694
|
this.decoder = new CodecWithFallback(
|
|
69699
69695
|
new ThreadedImageDecoder(),
|
|
69700
|
-
|
|
69696
|
+
new NativeImageDecoder()
|
|
69701
69697
|
);
|
|
69702
69698
|
}
|
|
69703
69699
|
|
package/package.json
CHANGED
|
@@ -14,7 +14,13 @@ import { v3_dot } from "../../vec3/v3_dot.js";
|
|
|
14
14
|
* @param {number} pz
|
|
15
15
|
* @returns {number} distance from origin, negative means that the point lies behind the origin in the direction opposite to the ray's own
|
|
16
16
|
*/
|
|
17
|
-
export function ray_computeNearestPointToPoint(
|
|
17
|
+
export function ray_computeNearestPointToPoint(
|
|
18
|
+
result,
|
|
19
|
+
origin_x, origin_y, origin_z,
|
|
20
|
+
direction_x, direction_y, direction_z,
|
|
21
|
+
px, py, pz
|
|
22
|
+
) {
|
|
23
|
+
|
|
18
24
|
// find closest point
|
|
19
25
|
const sp0_x = px - origin_x;
|
|
20
26
|
const sp0_y = py - origin_y;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v3_dot } from "../../../vec3/v3_dot.js";
|
|
2
|
-
import {
|
|
2
|
+
import { v3_compute_triangle_normal } from "../../v3_compute_triangle_normal.js";
|
|
3
3
|
|
|
4
|
-
const scratch_normal = new Float32Array(
|
|
4
|
+
const scratch_normal = new Float32Array(6);
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Used to detect face normal flips for mesh optimization.
|
|
@@ -38,44 +38,24 @@ export function compute_face_normal_change_dot_product(face, vertex_old, vertex_
|
|
|
38
38
|
v2 = vertex_new;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// compute
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const vCBy = vCy - vBy;
|
|
57
|
-
const vCBz = vCz - vBz;
|
|
58
|
-
|
|
59
|
-
const vABx = vAx - vBx;
|
|
60
|
-
const vABy = vAy - vBy;
|
|
61
|
-
const vABz = vAz - vBz;
|
|
62
|
-
|
|
63
|
-
//compute triangle normal
|
|
64
|
-
const crossX = vCBy * vABz - vCBz * vABy;
|
|
65
|
-
const crossY = vCBz * vABx - vCBx * vABz;
|
|
66
|
-
const crossZ = vCBx * vABy - vCBy * vABx;
|
|
67
|
-
|
|
68
|
-
// compute face normal
|
|
69
|
-
const vertices = face.vertices;
|
|
70
|
-
|
|
71
|
-
const vA = vertices[0];
|
|
72
|
-
const vB = vertices[1];
|
|
73
|
-
const vC = vertices[2];
|
|
74
|
-
|
|
75
|
-
compute_triangle_normal(scratch_normal, vA, vB, vC);
|
|
41
|
+
// compute modified face normal
|
|
42
|
+
v3_compute_triangle_normal(
|
|
43
|
+
scratch_normal, 0,
|
|
44
|
+
v0.x, v0.y, v0.z,
|
|
45
|
+
v1.x, v1.y, v1.z,
|
|
46
|
+
v2.x, v2.y, v2.z
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
// compute current face normal
|
|
50
|
+
v3_compute_triangle_normal(
|
|
51
|
+
scratch_normal, 3,
|
|
52
|
+
original_v0.x, original_v0.y, original_v0.z,
|
|
53
|
+
original_v1.x, original_v1.y, original_v1.z,
|
|
54
|
+
original_v2.x, original_v2.y, original_v2.z
|
|
55
|
+
)
|
|
76
56
|
|
|
77
57
|
return v3_dot(
|
|
78
|
-
|
|
79
|
-
scratch_normal[
|
|
58
|
+
scratch_normal[0], scratch_normal[1], scratch_normal[2],
|
|
59
|
+
scratch_normal[3], scratch_normal[4], scratch_normal[5]
|
|
80
60
|
);
|
|
81
61
|
}
|
|
@@ -659,65 +659,6 @@ class Quaternion {
|
|
|
659
659
|
result.set(psi, theta, phi);
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
/**
|
|
663
|
-
*
|
|
664
|
-
* @param {Matrix4} m
|
|
665
|
-
*/
|
|
666
|
-
threeSetRotationMatrix(m) {
|
|
667
|
-
throw new Error('Deprecated');
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
/**
|
|
671
|
-
* Read out rotation into a matrix
|
|
672
|
-
* @param {Array<Number>} elements
|
|
673
|
-
*/
|
|
674
|
-
setRotationMatrix(elements) {
|
|
675
|
-
const x = this.x;
|
|
676
|
-
const y = this.y;
|
|
677
|
-
const z = this.z;
|
|
678
|
-
const w = this.w;
|
|
679
|
-
|
|
680
|
-
const x2 = x + x;
|
|
681
|
-
const y2 = y + y;
|
|
682
|
-
const z2 = z + z;
|
|
683
|
-
|
|
684
|
-
const xx = x * x2;
|
|
685
|
-
const xy = x * y2;
|
|
686
|
-
const xz = x * z2;
|
|
687
|
-
|
|
688
|
-
const yy = y * y2;
|
|
689
|
-
const yz = y * z2;
|
|
690
|
-
const zz = z * z2;
|
|
691
|
-
|
|
692
|
-
const wx = w * x2;
|
|
693
|
-
const wy = w * y2;
|
|
694
|
-
const wz = w * z2;
|
|
695
|
-
|
|
696
|
-
// set 3x3 rotation matrix
|
|
697
|
-
elements[0] = 1 - (yy + zz);
|
|
698
|
-
elements[4] = xy - wz;
|
|
699
|
-
elements[8] = xz + wy;
|
|
700
|
-
|
|
701
|
-
elements[1] = xy + wz;
|
|
702
|
-
elements[5] = 1 - (xx + zz);
|
|
703
|
-
elements[9] = yz - wx;
|
|
704
|
-
|
|
705
|
-
elements[2] = xz - wy;
|
|
706
|
-
elements[6] = yz + wx;
|
|
707
|
-
elements[10] = 1 - (xx + yy);
|
|
708
|
-
|
|
709
|
-
// last column
|
|
710
|
-
elements[3] = 0;
|
|
711
|
-
elements[7] = 0;
|
|
712
|
-
elements[11] = 0;
|
|
713
|
-
|
|
714
|
-
// bottom row
|
|
715
|
-
elements[12] = 0;
|
|
716
|
-
elements[13] = 0;
|
|
717
|
-
elements[14] = 0;
|
|
718
|
-
elements[15] = 1;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
662
|
/**
|
|
722
663
|
* XYZ order
|
|
723
664
|
* @source: https://stackoverflow.com/questions/12088610/conversion-between-euler-quaternion-like-in-unity3d-engine
|
|
@@ -4,6 +4,7 @@ import { GameAssetType } from "../../GameAssetType.js";
|
|
|
4
4
|
import { ArrayBufferLoader } from "../ArrayBufferLoader.js";
|
|
5
5
|
import { AssetLoader } from "../AssetLoader.js";
|
|
6
6
|
import { CodecWithFallback } from "./codec/CodecWithFallback.js";
|
|
7
|
+
import { NativeImageDecoder } from "./codec/NativeImageDecoder.js";
|
|
7
8
|
import { ThreadedImageDecoder } from "./codec/ThreadedImageDecoder.js";
|
|
8
9
|
import { ImageRGBADataAsset } from "./ImageRGBADataAsset.js";
|
|
9
10
|
|
|
@@ -15,7 +16,7 @@ export class ImageRGBADataLoader extends AssetLoader {
|
|
|
15
16
|
|
|
16
17
|
this.decoder = new CodecWithFallback(
|
|
17
18
|
new ThreadedImageDecoder(),
|
|
18
|
-
|
|
19
|
+
new NativeImageDecoder()
|
|
19
20
|
);
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { System } from "../../../../ecs/System.js";
|
|
2
|
-
import { SGMesh } from "./SGMesh.js";
|
|
3
2
|
import Highlight from "../../highlight/Highlight.js";
|
|
3
|
+
import { SGMesh } from "./SGMesh.js";
|
|
4
4
|
import { SGMeshEvents } from "./SGMeshEvents.js";
|
|
5
5
|
|
|
6
6
|
export class SGMeshHighlightSystem extends System {
|
|
@@ -33,6 +33,12 @@ export class SGMeshHighlightSystem extends System {
|
|
|
33
33
|
|
|
34
34
|
const node = sg_mesh.__node;
|
|
35
35
|
|
|
36
|
+
if (node === null) {
|
|
37
|
+
// not loaded yet
|
|
38
|
+
console.warn(`SGMesh is not loaded yet: ${sg_mesh.url}`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
36
42
|
node.traverse(t => {
|
|
37
43
|
t.entity.add(highlight);
|
|
38
44
|
});
|
|
@@ -3,6 +3,8 @@ import {AttributeSpec} from "./AttributeSpec";
|
|
|
3
3
|
export class VertexDataSpec {
|
|
4
4
|
readonly attributes: AttributeSpec[]
|
|
5
5
|
|
|
6
|
+
static from(...attributes: AttributeSpec[]): VertexDataSpec
|
|
7
|
+
|
|
6
8
|
getAttributeByName(name: string): AttributeSpec | undefined
|
|
7
9
|
|
|
8
10
|
add(attribute: AttributeSpec): this
|
|
@@ -12,4 +14,12 @@ export class VertexDataSpec {
|
|
|
12
14
|
equals(other: VertexDataSpec): boolean
|
|
13
15
|
|
|
14
16
|
hash(): number
|
|
17
|
+
|
|
18
|
+
toJSON(): any
|
|
19
|
+
|
|
20
|
+
fromJSON(json: any): void
|
|
21
|
+
|
|
22
|
+
getByteSize(): number
|
|
23
|
+
|
|
24
|
+
readonly isVertexDataSpec: true
|
|
15
25
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assert } from "../../../core/assert.js";
|
|
2
2
|
import { computeHashArray } from "../../../core/collection/array/computeHashArray.js";
|
|
3
3
|
import { isArrayEqual } from "../../../core/collection/array/isArrayEqual.js";
|
|
4
|
+
import { invokeObjectHash } from "../../../core/model/object/invokeObjectHash.js";
|
|
4
5
|
import { AttributeSpec } from "./AttributeSpec.js";
|
|
5
|
-
import { assert } from "../../../core/assert.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @readonly
|
|
@@ -15,20 +15,19 @@ const DEFAULT_HASH = 1234567;
|
|
|
15
15
|
* @example "uv","position" and "normal" attributes of geometry vertices
|
|
16
16
|
*/
|
|
17
17
|
export class VertexDataSpec {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {AttributeSpec[]}
|
|
22
|
+
*/
|
|
23
|
+
attributes = [];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Cached hash for speed
|
|
27
|
+
* @type {number}
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
#hash = DEFAULT_HASH;
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
33
|
*
|
|
@@ -112,7 +111,7 @@ export class VertexDataSpec {
|
|
|
112
111
|
this.attributes.push(attribute);
|
|
113
112
|
|
|
114
113
|
// reset hash
|
|
115
|
-
this
|
|
114
|
+
this.#hash = DEFAULT_HASH;
|
|
116
115
|
|
|
117
116
|
//for chaining, return self
|
|
118
117
|
return this;
|
|
@@ -138,7 +137,7 @@ export class VertexDataSpec {
|
|
|
138
137
|
this.attributes.splice(0, this.attributes.length);
|
|
139
138
|
|
|
140
139
|
// reset hash to trigger hash update
|
|
141
|
-
this
|
|
140
|
+
this.#hash = DEFAULT_HASH;
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
/**
|
|
@@ -159,11 +158,11 @@ export class VertexDataSpec {
|
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
hash() {
|
|
162
|
-
if (this
|
|
163
|
-
this
|
|
161
|
+
if (this.#hash === DEFAULT_HASH) {
|
|
162
|
+
this.#hash = this.computeHash();
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
return this
|
|
165
|
+
return this.#hash;
|
|
167
166
|
}
|
|
168
167
|
|
|
169
168
|
toJSON() {
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
2
1
|
import {
|
|
3
2
|
DoubleSide,
|
|
3
|
+
GLSL3,
|
|
4
4
|
LinearFilter,
|
|
5
5
|
Mesh as ThreeMesh,
|
|
6
6
|
OrthographicCamera,
|
|
7
|
+
RedIntegerFormat,
|
|
8
|
+
RGBAIntegerFormat,
|
|
9
|
+
RGBIntegerFormat,
|
|
10
|
+
RGIntegerFormat,
|
|
7
11
|
Scene,
|
|
8
12
|
ShaderMaterial,
|
|
9
|
-
UnsignedByteType,
|
|
10
13
|
WebGLRenderTarget
|
|
11
14
|
} from "three";
|
|
12
|
-
import
|
|
15
|
+
import { assert } from "../../../../../core/assert.js";
|
|
16
|
+
import { UINT32_MAX } from "../../../../../core/binary/UINT32_MAX.js";
|
|
17
|
+
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
13
18
|
import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../../../geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js";
|
|
14
|
-
import { formatToChannelCount } from "../../../texture/formatToChannelCount.js";
|
|
15
19
|
import { glsl_gen_swizzled_read } from "../../../shaders/glsl_gen_swizzled_read.js";
|
|
16
|
-
import
|
|
20
|
+
import CheckersTexture from "../../../texture/CheckersTexture.js";
|
|
21
|
+
import { formatToChannelCount } from "../../../texture/formatToChannelCount.js";
|
|
17
22
|
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
18
23
|
|
|
19
24
|
|
|
@@ -24,7 +29,10 @@ import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
|
24
29
|
*/
|
|
25
30
|
function defineSamplerType(texture) {
|
|
26
31
|
switch (texture.format) {
|
|
27
|
-
case
|
|
32
|
+
case RedIntegerFormat:
|
|
33
|
+
case RGIntegerFormat:
|
|
34
|
+
case RGBIntegerFormat:
|
|
35
|
+
case RGBAIntegerFormat:
|
|
28
36
|
return 'usampler2D';
|
|
29
37
|
default:
|
|
30
38
|
return 'sampler2D'
|
|
@@ -39,9 +47,29 @@ function defineSamplerType(texture) {
|
|
|
39
47
|
* @returns {string}
|
|
40
48
|
*/
|
|
41
49
|
function sampleTexel(texture, name, uv) {
|
|
50
|
+
|
|
51
|
+
const texture_sample = `texture2D(${name}, ${uv})`;
|
|
52
|
+
|
|
42
53
|
switch (texture.format) {
|
|
54
|
+
case RedIntegerFormat:
|
|
55
|
+
return `vec4(${texture_sample})`;
|
|
43
56
|
default:
|
|
44
|
-
return
|
|
57
|
+
return texture_sample;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param {THREE.Texture} texture
|
|
64
|
+
* @param {string} sample
|
|
65
|
+
* @retunrs {string}
|
|
66
|
+
*/
|
|
67
|
+
function scaleSample(texture, sample) {
|
|
68
|
+
switch (texture.internalFormat) {
|
|
69
|
+
case "R32UI":
|
|
70
|
+
return `${sample} * ${1 / UINT32_MAX}`
|
|
71
|
+
default:
|
|
72
|
+
return sample;
|
|
45
73
|
}
|
|
46
74
|
}
|
|
47
75
|
|
|
@@ -76,20 +104,23 @@ function makeShader({ texture, alpha_override, swizzle }) {
|
|
|
76
104
|
|
|
77
105
|
fragmentShader: /* glsl */`
|
|
78
106
|
|
|
107
|
+
precision mediump usampler2D;
|
|
79
108
|
uniform ${defineSamplerType(texture)} tDiffuse;
|
|
80
109
|
|
|
81
110
|
varying vec2 vUv;
|
|
111
|
+
out vec4 out_frag;
|
|
82
112
|
|
|
83
113
|
void main() {
|
|
84
114
|
|
|
85
|
-
vec4 texel = ${sampleTexel(texture, 'tDiffuse', 'vUv')};
|
|
86
|
-
|
|
115
|
+
vec4 texel = ${scaleSample(texture, sampleTexel(texture, 'tDiffuse', 'vUv'))};
|
|
116
|
+
out_frag = ${glsl_gen_swizzled_read('texel', _swizzle)};
|
|
87
117
|
}`,
|
|
88
118
|
uniforms: {
|
|
89
119
|
|
|
90
120
|
'tDiffuse': { value: null }
|
|
91
121
|
|
|
92
|
-
}
|
|
122
|
+
},
|
|
123
|
+
glslVersion: GLSL3
|
|
93
124
|
});
|
|
94
125
|
}
|
|
95
126
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RedFormat, RGBAFormat, RGBFormat, RGFormat } from "three";
|
|
1
|
+
import { RedFormat, RedIntegerFormat, RGBAFormat, RGBFormat, RGFormat } from "three";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -8,6 +8,7 @@ import { RedFormat, RGBAFormat, RGBFormat, RGFormat } from "three";
|
|
|
8
8
|
export function formatToChannelCount(format) {
|
|
9
9
|
switch (format) {
|
|
10
10
|
case RedFormat:
|
|
11
|
+
case RedIntegerFormat:
|
|
11
12
|
return 1;
|
|
12
13
|
case RGFormat:
|
|
13
14
|
return 2;
|
|
@@ -60,14 +60,14 @@ export function sampler2d_scale_down_generic(
|
|
|
60
60
|
let z = 0;
|
|
61
61
|
for (j = source_y0; j <= source_y1; j++) {
|
|
62
62
|
|
|
63
|
-
const f_y = (j - center_y);
|
|
63
|
+
const f_y = (j - center_y) + 0.5;
|
|
64
64
|
|
|
65
65
|
const f_y_rcp = f_y * rcp_ratio_y;
|
|
66
66
|
const f_y_rcp2 = f_y_rcp * f_y_rcp;
|
|
67
67
|
|
|
68
68
|
for (i = source_x0; i <= source_x1; i++) {
|
|
69
69
|
|
|
70
|
-
const f_x = (i - center_x);
|
|
70
|
+
const f_x = (i - center_x) + 0.5;
|
|
71
71
|
|
|
72
72
|
const f_x_rcp = f_x * rcp_ratio_x;
|
|
73
73
|
const f_x_rcp2 = f_x_rcp * f_x_rcp;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { EngineHarness } from "../../../EngineHarness.js";
|
|
2
|
-
import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
3
|
-
import sampler2D2Canvas from "./Sampler2D2Canvas.js";
|
|
4
|
-
import { CanvasView } from "../../../../view/elements/CanvasView.js";
|
|
5
|
-
import { sampler2d_scale_down_lanczos } from "./resize/sampler2d_scale_down_lanczos.js";
|
|
6
|
-
import { Sampler2D } from "./Sampler2D.js";
|
|
7
|
-
import { sampler2d_scale_generic } from "./resize/sampler2d_scale_generic.js";
|
|
8
1
|
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
9
2
|
import LabelView from "../../../../view/common/LabelView.js";
|
|
3
|
+
import { CanvasView } from "../../../../view/elements/CanvasView.js";
|
|
10
4
|
import EmptyView from "../../../../view/elements/EmptyView.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { sampler2d_scale_down_generic } from "./filter/sampler2d_scale_down_generic.js";
|
|
14
|
-
import { mitchell } from "./filter/mitchell.js";
|
|
15
|
-
import { kaiser_1 } from "./filter/kaiser_1.js";
|
|
16
|
-
import { triangle } from "./filter/triangle.js";
|
|
5
|
+
import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
6
|
+
import { EngineHarness } from "../../../EngineHarness.js";
|
|
17
7
|
import { box } from "./filter/box.js";
|
|
8
|
+
import { filter_lanczos3 } from "./filter/filter_lanczos3.js";
|
|
18
9
|
import { gaussian } from "./filter/gaussian.js";
|
|
10
|
+
import { kaiser_1 } from "./filter/kaiser_1.js";
|
|
11
|
+
import { kaiser_bessel_window } from "./filter/kaiser_bessel_window.js";
|
|
12
|
+
import { mitchell } from "./filter/mitchell.js";
|
|
19
13
|
import { mitchell_v1 } from "./filter/mitchell_v1.js";
|
|
20
|
-
import {
|
|
14
|
+
import { sampler2d_scale_down_generic } from "./filter/sampler2d_scale_down_generic.js";
|
|
15
|
+
import { triangle } from "./filter/triangle.js";
|
|
16
|
+
import { sampler2d_scale_down_lanczos } from "./resize/sampler2d_scale_down_lanczos.js";
|
|
17
|
+
import { sampler2d_scale_down_mipmap } from "./resize/sampler2d_scale_down_mipmap.js";
|
|
18
|
+
import { sampler2d_scale_generic } from "./resize/sampler2d_scale_generic.js";
|
|
19
|
+
import { Sampler2D } from "./Sampler2D.js";
|
|
20
|
+
import sampler2D2Canvas from "./Sampler2D2Canvas.js";
|
|
21
21
|
|
|
22
22
|
function grid({ engine, input, transforms, size = new Vector2(input.width, input.height), display_labels = true }) {
|
|
23
23
|
|
|
@@ -126,9 +126,9 @@ new EngineHarness().initialize({
|
|
|
126
126
|
// const path = "data/textures/utility/image018.jpg";
|
|
127
127
|
// const path = "data/textures/decal/ISO 7010 - Safety Signs/Fire Protection/200px/F001 – Fire extinguisher.png";
|
|
128
128
|
// const path = "data/textures/decal/ISO 7010 - Safety Signs/Prohibited Actions/400px/P069 - Not to be serviced by users.png";
|
|
129
|
-
const path = "data/textures/utility/Lenna.png";
|
|
129
|
+
// const path = "data/textures/utility/Lenna.png";
|
|
130
130
|
// const path = "data/textures/utility/dragon.jpg";
|
|
131
|
-
|
|
131
|
+
const path = "data/textures/utility/grid_tileable.png";
|
|
132
132
|
// const path = "data/textures/utility/uv_map_reference.jpg";
|
|
133
133
|
// const path ="data/textures/utility/TESTIMAGES/SAMPLING/8BIT/RGB/2448x2448/SRC/img_2448x2448_3x8bit_SRC_RGB_clips.png";
|
|
134
134
|
// const path ="data/textures/utility/TESTIMAGES/SAMPLING/8BIT/RGB/2448x2448/SRC/img_2448x2448_3x8bit_SRC_RGB_coins.png";
|
|
@@ -303,7 +303,7 @@ function test_sampling(source, engine) {
|
|
|
303
303
|
|
|
304
304
|
// return;
|
|
305
305
|
|
|
306
|
-
sampler2d_scale_down_generic(input, out, kaiser_bessel_window);
|
|
306
|
+
sampler2d_scale_down_generic(input, out, kaiser_bessel_window,1);
|
|
307
307
|
|
|
308
308
|
},
|
|
309
309
|
(out, input, params) => {
|
|
@@ -312,7 +312,7 @@ function test_sampling(source, engine) {
|
|
|
312
312
|
|
|
313
313
|
// return;
|
|
314
314
|
|
|
315
|
-
sampler2d_scale_down_generic(input, out, kaiser_1);
|
|
315
|
+
sampler2d_scale_down_generic(input, out, kaiser_1,1);
|
|
316
316
|
|
|
317
317
|
},
|
|
318
318
|
(out, input, params) => {
|
|
@@ -345,7 +345,8 @@ function test_sampling(source, engine) {
|
|
|
345
345
|
], size: new Vector2(
|
|
346
346
|
// 100, 100
|
|
347
347
|
// 1024, 1024
|
|
348
|
-
|
|
348
|
+
// 256, 256
|
|
349
|
+
128, 128
|
|
349
350
|
// 64, 64
|
|
350
351
|
// 32,32
|
|
351
352
|
// 400,400
|