@woosh/meep-engine 2.93.2 → 2.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +296 -233
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +296 -233
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/BVH.js +4 -2
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +2 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +12 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +11 -1
- package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.d.ts +14 -0
- package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.js +146 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts +16 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js +90 -0
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +17 -7
- package/src/core/geom/2d/bvh/BVH2D.d.ts.map +1 -1
- package/src/core/geom/2d/bvh/BVH2D.js +24 -29
- package/src/core/geom/2d/bvh/BVH2D.spec.js +10 -9
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.d.ts +2 -0
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.d.ts.map +1 -0
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.js +89 -0
- package/src/core/geom/2d/quad-tree/QuadTreeNode.spec.js +1 -1
- package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +8 -1
- package/src/core/geom/3d/aabb/aabb3_array_combine.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_array_combine.js +5 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +2 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.d.ts.map +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +9 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.d.ts +16 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js +55 -0
- package/src/core/math/build_gaussian_kernel_1d.d.ts +8 -0
- package/src/core/math/build_gaussian_kernel_1d.d.ts.map +1 -0
- package/src/core/math/build_gaussian_kernel_1d.js +26 -0
- package/src/core/math/build_gaussian_kernel_2d.d.ts +10 -0
- package/src/core/math/build_gaussian_kernel_2d.d.ts.map +1 -0
- package/src/core/math/build_gaussian_kernel_2d.js +55 -0
- package/src/core/math/nextOdd.d.ts +8 -0
- package/src/core/math/nextOdd.d.ts.map +1 -0
- package/src/core/math/nextOdd.js +15 -0
- package/src/core/math/nextOdd.spec.d.ts +2 -0
- package/src/core/math/nextOdd.spec.d.ts.map +1 -0
- package/src/core/math/nextOdd.spec.js +9 -0
- package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -1
- package/src/engine/animation/clip/ecd_bind_animation_curve.js +7 -3
- package/src/engine/animation/curve/prototypeGLTF.js +18 -11
- package/src/engine/ecs/Entity.js +1 -1
- package/src/engine/ecs/EntityComponentDataset.js +0 -14
- package/src/engine/ecs/computeComponentClassName.d.ts +2 -0
- package/src/engine/ecs/computeComponentClassName.d.ts.map +1 -0
- package/src/engine/ecs/computeComponentClassName.js +13 -0
- package/src/engine/graphics/ecs/light/binding/LightBinding.d.ts +2 -0
- package/src/engine/graphics/ecs/light/binding/LightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/LightBinding.js +16 -0
- package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.d.ts +13 -2
- package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.js +37 -4
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +12 -8
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.d.ts +0 -9
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +100 -129
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -4
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +11 -4
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +2 -2
- package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +6 -4
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.js +1 -2
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.d.ts +2 -2
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js +3 -3
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js +5 -31
- package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.d.ts +3 -6
- package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.js +8 -27
- package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.d.ts +4 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.js +12 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureSystem.d.ts +29 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureSystem.d.ts.map +1 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureSystem.js +102 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js +1 -1
- package/src/engine/graphics/texture/virtual/prototype.js +221 -79
- package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
- package/src/generation/filtering/numeric/CellFilterCache.js +7 -7
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.js +9 -6
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts +1 -13
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +39 -111
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +6 -5
- package/src/generation/grid/generation/util/buildDistanceMapToObjective.d.ts +1 -1
- package/src/generation/grid/generation/util/buildDistanceMapToObjective.d.ts.map +1 -1
- package/src/generation/grid/generation/util/buildDistanceMapToObjective.js +5 -12
- package/src/core/math/makeNextOdd.d.ts +0 -8
- package/src/core/math/makeNextOdd.d.ts.map +0 -1
- package/src/core/math/makeNextOdd.js +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"downloadSamplerAsPNG.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"downloadSamplerAsPNG.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,uEAFW,MAAM,QAQhB"}
|
|
@@ -4,12 +4,12 @@ import { convertSampler2D2DataURL } from "./convertSampler2D2DataURL.js";
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param {Sampler2D} sampler
|
|
7
|
-
* @param {string} [
|
|
7
|
+
* @param {string} [file_name] what should the file be named?
|
|
8
8
|
*/
|
|
9
|
-
export function downloadSampler2DAsPNG(sampler,
|
|
9
|
+
export function downloadSampler2DAsPNG(sampler, file_name = 'image') {
|
|
10
10
|
|
|
11
11
|
const dataURL = convertSampler2D2DataURL(sampler);
|
|
12
12
|
|
|
13
|
-
downloadUrlAsFile(dataURL, `${
|
|
13
|
+
downloadUrlAsFile(dataURL, `${file_name}.png`);
|
|
14
14
|
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampler2d_blur_gaussian.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sampler2d_blur_gaussian.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,gDALW,SAAS,SACT,SAAS,QACT,MAAM,YACN,MAAM,QAoFhB;0BA9FyB,iBAAiB"}
|
|
@@ -1,36 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { makeNextOdd } from "../../../../../core/math/makeNextOdd.js";
|
|
1
|
+
import { build_gaussian_kernel_1d } from "../../../../../core/math/build_gaussian_kernel_1d.js";
|
|
3
2
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
3
|
+
import { nextOdd } from "../../../../../core/math/nextOdd.js";
|
|
4
4
|
import { Sampler2D } from "../Sampler2D.js";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
let temp_data = new Float64Array(1);
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {number} sample_count
|
|
12
|
-
* @param {number} sigma
|
|
13
|
-
* @param {Float32Array} kernel
|
|
14
|
-
*/
|
|
15
|
-
function build_kernel(sample_count, sigma, kernel) {
|
|
16
|
-
|
|
17
|
-
const half_width = (sample_count - 1) * 0.5;
|
|
18
|
-
|
|
19
|
-
let kernel_power_sum = 0;
|
|
20
|
-
for (let i = 0; i < sample_count; i++) {
|
|
21
|
-
const local = i - half_width;
|
|
22
|
-
|
|
23
|
-
const power = gaussian(sigma, local);
|
|
24
|
-
kernel[i] = power;
|
|
25
|
-
kernel_power_sum += power;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// normalize kernel
|
|
29
|
-
for (let i = 0; i < sample_count; i++) {
|
|
30
|
-
kernel[i] /= kernel_power_sum;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
9
|
/**
|
|
35
10
|
*
|
|
36
11
|
* @param {Sampler2D} output
|
|
@@ -41,11 +16,11 @@ function build_kernel(sample_count, sigma, kernel) {
|
|
|
41
16
|
export function sampler2d_blur_gaussian(output, input, size, quality = 1) {
|
|
42
17
|
|
|
43
18
|
const sigma = size * 3;
|
|
44
|
-
const sample_count = max2(3,
|
|
19
|
+
const sample_count = max2(3, nextOdd(Math.round(size * quality)));
|
|
45
20
|
|
|
46
21
|
const kernel = new Float32Array(sample_count);
|
|
47
22
|
|
|
48
|
-
|
|
23
|
+
build_gaussian_kernel_1d(kernel, sample_count, sigma);
|
|
49
24
|
|
|
50
25
|
const width = input.width;
|
|
51
26
|
const height = input.height;
|
|
@@ -53,6 +28,7 @@ export function sampler2d_blur_gaussian(output, input, size, quality = 1) {
|
|
|
53
28
|
|
|
54
29
|
const total_value_count = width * height * channel_count;
|
|
55
30
|
if (temp_data.length < total_value_count) {
|
|
31
|
+
// our static temp buffer is too small, let's make it larger
|
|
56
32
|
temp_data = new Float64Array(total_value_count);
|
|
57
33
|
}
|
|
58
34
|
|
|
@@ -93,8 +69,6 @@ export function sampler2d_blur_gaussian(output, input, size, quality = 1) {
|
|
|
93
69
|
source = target;
|
|
94
70
|
target = output;
|
|
95
71
|
|
|
96
|
-
// typed_array_copy(source.data, target.data);
|
|
97
|
-
|
|
98
72
|
// vertical pass
|
|
99
73
|
for (let y = 0; y < height; y++) {
|
|
100
74
|
for (let x = 0; x < width; x++) {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
export class VirtualTextureMaterial extends ShaderMaterial {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @param {VirtualTextureMemoryMapping} mapping
|
|
6
|
-
*/
|
|
7
|
-
constructor({ page, mapping }: VirtualTexturePage);
|
|
2
|
+
constructor({ uniforms }: {
|
|
3
|
+
uniforms: any;
|
|
4
|
+
});
|
|
8
5
|
}
|
|
9
6
|
import { ShaderMaterial } from "three";
|
|
10
7
|
//# sourceMappingURL=VirtualTextureMaterial.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualTextureMaterial.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/virtual/VirtualTextureMaterial.js"],"names":[],"mappings":"AAEA;IACI
|
|
1
|
+
{"version":3,"file":"VirtualTextureMaterial.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/virtual/VirtualTextureMaterial.js"],"names":[],"mappings":"AAEA;IACI;;OAyKC;CACJ;+BA7K0C,OAAO"}
|
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
import { DoubleSide, ShaderMaterial
|
|
1
|
+
import { DoubleSide, ShaderMaterial } from "three";
|
|
2
2
|
|
|
3
3
|
export class VirtualTextureMaterial extends ShaderMaterial {
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {VirtualTexturePage} page
|
|
7
|
-
* @param {VirtualTextureMemoryMapping} mapping
|
|
8
|
-
*/
|
|
9
4
|
constructor({
|
|
10
|
-
|
|
11
|
-
mapping
|
|
5
|
+
uniforms
|
|
12
6
|
}) {
|
|
13
7
|
super({
|
|
14
8
|
side: DoubleSide,
|
|
15
|
-
uniforms
|
|
16
|
-
u_page: { value: page.texture },
|
|
17
|
-
u_page_resolution: {
|
|
18
|
-
value: new Vector2(
|
|
19
|
-
page.page_texture_resolution_in_tiles[0],
|
|
20
|
-
page.page_texture_resolution_in_tiles[1]
|
|
21
|
-
)
|
|
22
|
-
},
|
|
23
|
-
u_tile_resolution: { value: page.tile_resolution },
|
|
24
|
-
u_tile_padding: { value: page.tile_margin },
|
|
25
|
-
u_mapping: { value: mapping.texture },
|
|
26
|
-
u_texture_resolution: { value: mapping.resolution * page.tile_resolution },
|
|
27
|
-
u_max_mip_level: { value: mapping.max_mip_level },
|
|
28
|
-
u_mapping_texture_width: { value: mapping.texture.image.width }
|
|
29
|
-
},
|
|
9
|
+
uniforms,
|
|
30
10
|
vertexShader: `
|
|
31
11
|
|
|
32
12
|
// uniform mat4 modelViewMatrix;
|
|
@@ -130,7 +110,7 @@ export class VirtualTextureMaterial extends ShaderMaterial {
|
|
|
130
110
|
return vec2(tp00) + tile_uv;
|
|
131
111
|
}
|
|
132
112
|
|
|
133
|
-
vec4 VirtualFetchLod(const in vec2 uv,const in uint texture_lod_0){
|
|
113
|
+
vec4 VirtualFetchLod(const in vec2 uv, const in uint texture_lod_0){
|
|
134
114
|
uint ui_texture_lod_0 = u_max_mip_level - texture_lod_0;
|
|
135
115
|
uint tile_mip_size = 1u << ui_texture_lod_0;
|
|
136
116
|
|
|
@@ -144,10 +124,9 @@ export class VirtualTextureMaterial extends ShaderMaterial {
|
|
|
144
124
|
float f_tile_resolution = float(u_tile_resolution);
|
|
145
125
|
float slot_size = float(u_tile_resolution + u_tile_padding*2u);
|
|
146
126
|
|
|
147
|
-
ivec2 texture_size = textureSize(u_page,0);
|
|
127
|
+
ivec2 texture_size = textureSize(u_page, 0);
|
|
148
128
|
|
|
149
|
-
vec2 texel = tile_offset * slot_size + float(u_tile_padding) + tile_uv*(f_tile_resolution)
|
|
150
|
-
// vec2 texel = tile_offset * slot_size + float(u_tile_padding) + tile_uv*(f_tile_resolution) - 0.5;
|
|
129
|
+
vec2 texel = tile_offset * slot_size + float(u_tile_padding) + tile_uv*(f_tile_resolution);
|
|
151
130
|
|
|
152
131
|
vec2 page_uv = texel / vec2(texture_size);
|
|
153
132
|
|
|
@@ -179,6 +158,8 @@ export class VirtualTextureMaterial extends ShaderMaterial {
|
|
|
179
158
|
|
|
180
159
|
// return texelFetch( u_page, tuv, 0 );
|
|
181
160
|
|
|
161
|
+
// return VirtualFetchLod(uv, 7u);
|
|
162
|
+
// return vec4(uv, texture_lod / 7.0,1.0);
|
|
182
163
|
}
|
|
183
164
|
|
|
184
165
|
void main(){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualTextureMemoryMapping.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.js"],"names":[],"mappings":"AAcA;;GAEG;AACH;IAQI,4BAEC;IAWD,2BAEC;IAeD;;;OAGG;IACH,4BAiCC;IAED,yBAEC;IAED;;;OAGG;IACH,uCAsEC;IAGD,gBAEC;;CACJ;
|
|
1
|
+
{"version":3,"file":"VirtualTextureMemoryMapping.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.js"],"names":[],"mappings":"AAcA;;GAEG;AACH;IAQI,4BAEC;IAWD,2BAEC;IAeD;;;OAGG;IACH,4BAiCC;IAED,yBAEC;IAED;;;OAGG;IACH,uCAsEC;IAED;;;MAUC;IAGD,gBAEC;;CACJ;4BA9LkG,OAAO"}
|
|
@@ -172,6 +172,18 @@ export class VirtualTextureMemoryMapping {
|
|
|
172
172
|
this.#texture.needsUpdate = true;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
getTileMetadata(x,y,mip){
|
|
176
|
+
|
|
177
|
+
const tile_address = compose_tile_address(mip, x, y);
|
|
178
|
+
|
|
179
|
+
const encoded_tile = this.#pyramid[tile_address];
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
slot: encoded_tile & 0x3FFFFF,
|
|
183
|
+
mip: ((encoded_tile >> 22) & 0x3FF)
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
175
187
|
|
|
176
188
|
dispose() {
|
|
177
189
|
this.#texture.dispose();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class VirtualTextureSystem {
|
|
2
|
+
updater: VirtualTextureUsageUpdater;
|
|
3
|
+
page: VirtualTexturePage;
|
|
4
|
+
mapping: VirtualTextureMemoryMapping;
|
|
5
|
+
setTexture({ path, texture_resolution, tile_resolution, tile_margin, }: {
|
|
6
|
+
path: any;
|
|
7
|
+
texture_resolution: any;
|
|
8
|
+
tile_resolution: any;
|
|
9
|
+
tile_margin: any;
|
|
10
|
+
}): void;
|
|
11
|
+
initialize({ page_resolution, asset_manager }: {
|
|
12
|
+
page_resolution?: number;
|
|
13
|
+
asset_manager: any;
|
|
14
|
+
}): void;
|
|
15
|
+
makeMaterial(): VirtualTextureMaterial;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {WebGLRenderer} renderer
|
|
19
|
+
* @param {Scene} scene
|
|
20
|
+
* @param {Camera} camera
|
|
21
|
+
*/
|
|
22
|
+
update(renderer: WebGLRenderer, scene: Scene, camera: Camera): void;
|
|
23
|
+
#private;
|
|
24
|
+
}
|
|
25
|
+
import { VirtualTextureUsageUpdater } from "./VirtualTextureUsageUpdater.js";
|
|
26
|
+
import { VirtualTexturePage } from "./VirtualTexturePage.js";
|
|
27
|
+
import { VirtualTextureMemoryMapping } from "./VirtualTextureMemoryMapping.js";
|
|
28
|
+
import { VirtualTextureMaterial } from "./VirtualTextureMaterial.js";
|
|
29
|
+
//# sourceMappingURL=VirtualTextureSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualTextureSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/virtual/VirtualTextureSystem.js"],"names":[],"mappings":"AAMA;IACI,oCAA0C;IAC1C,yBAA+B;IAC/B,qCAA2C;IAgB3C;;;;;aAeC;IAsBD;;;aAWC;IAED,uCAIC;IAED;;;;;OAKG;IACH,oEAaC;;CACJ;2CAjG0C,iCAAiC;mCADzC,yBAAyB;4CADhB,kCAAkC;uCADvC,6BAA6B"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Vector2 } from "three";
|
|
2
|
+
import { VirtualTextureMaterial } from "./VirtualTextureMaterial.js";
|
|
3
|
+
import { VirtualTextureMemoryMapping } from "./VirtualTextureMemoryMapping.js";
|
|
4
|
+
import { VirtualTexturePage } from "./VirtualTexturePage.js";
|
|
5
|
+
import { VirtualTextureUsageUpdater } from "./VirtualTextureUsageUpdater.js";
|
|
6
|
+
|
|
7
|
+
export class VirtualTextureSystem {
|
|
8
|
+
updater = new VirtualTextureUsageUpdater()
|
|
9
|
+
page = new VirtualTexturePage()
|
|
10
|
+
mapping = new VirtualTextureMemoryMapping()
|
|
11
|
+
|
|
12
|
+
#managed_materials_uniforms = {
|
|
13
|
+
|
|
14
|
+
u_page: { value: null },
|
|
15
|
+
u_page_resolution: {
|
|
16
|
+
value: new Vector2(0, 0)
|
|
17
|
+
},
|
|
18
|
+
u_tile_resolution: { value: 1 },
|
|
19
|
+
u_tile_padding: { value: 0 },
|
|
20
|
+
u_mapping: { value: null },
|
|
21
|
+
u_texture_resolution: { value: 0 },
|
|
22
|
+
u_max_mip_level: { value: 0 },
|
|
23
|
+
u_mapping_texture_width: { value: 0 }
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
setTexture({
|
|
27
|
+
path,
|
|
28
|
+
texture_resolution,
|
|
29
|
+
tile_resolution,
|
|
30
|
+
tile_margin,
|
|
31
|
+
}) {
|
|
32
|
+
this.updater.setTextureParameters(
|
|
33
|
+
texture_resolution,
|
|
34
|
+
tile_resolution,
|
|
35
|
+
3
|
|
36
|
+
);
|
|
37
|
+
this.page.tile_resolution = this.updater.tile_resolution;
|
|
38
|
+
this.page.path = path;
|
|
39
|
+
|
|
40
|
+
this.mapping.resolution = this.updater.texture_resolution / this.updater.tile_resolution;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#updateUniforms() {
|
|
44
|
+
const uniforms = this.#managed_materials_uniforms;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const page = this.page;
|
|
48
|
+
const mapping = this.mapping;
|
|
49
|
+
|
|
50
|
+
uniforms.u_page.value = page.texture;
|
|
51
|
+
uniforms.u_page_resolution.value.set(
|
|
52
|
+
page.page_texture_resolution_in_tiles[0],
|
|
53
|
+
page.page_texture_resolution_in_tiles[1]
|
|
54
|
+
);
|
|
55
|
+
uniforms.u_tile_resolution.value = page.tile_resolution;
|
|
56
|
+
uniforms.u_tile_padding.value = page.tile_margin;
|
|
57
|
+
uniforms.u_mapping.value = mapping.texture;
|
|
58
|
+
uniforms.u_texture_resolution.value = mapping.resolution * page.tile_resolution;
|
|
59
|
+
uniforms.u_max_mip_level.value = mapping.max_mip_level;
|
|
60
|
+
uniforms.u_mapping_texture_width.value = mapping.texture.image.width;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
initialize({
|
|
64
|
+
page_resolution = 2048,
|
|
65
|
+
asset_manager
|
|
66
|
+
}) {
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
this.page.page_texture_size = [page_resolution, page_resolution];
|
|
70
|
+
this.page.asset_manager = asset_manager;
|
|
71
|
+
// this.page.tile_margin = tile_margin;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
makeMaterial() {
|
|
77
|
+
return new VirtualTextureMaterial({
|
|
78
|
+
uniforms: this.#managed_materials_uniforms
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @param {WebGLRenderer} renderer
|
|
85
|
+
* @param {Scene} scene
|
|
86
|
+
* @param {Camera} camera
|
|
87
|
+
*/
|
|
88
|
+
update(renderer, scene, camera) {
|
|
89
|
+
this.page.renderer = renderer;
|
|
90
|
+
|
|
91
|
+
const view_port_size = renderer.getSize(new Vector2());
|
|
92
|
+
view_port_size.multiplyScalar(renderer.getPixelRatio());
|
|
93
|
+
|
|
94
|
+
this.updater.setViewportResolution(view_port_size.x, view_port_size.y);
|
|
95
|
+
this.updater.updateUsage(renderer, scene, camera);
|
|
96
|
+
this.page.update_usage(this.updater.usage_metadata);
|
|
97
|
+
this.mapping.residency = this.page;
|
|
98
|
+
|
|
99
|
+
//
|
|
100
|
+
this.#updateUniforms();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -83,7 +83,7 @@ export class VirtualTextureUsageUpdater {
|
|
|
83
83
|
*/
|
|
84
84
|
#frame_jitter_offsets = new Float32Array([0, 0]);
|
|
85
85
|
#frame_jitter_samples = 1;
|
|
86
|
-
#frame_jitter_enabled =
|
|
86
|
+
#frame_jitter_enabled = false;
|
|
87
87
|
|
|
88
88
|
get frame_jitter_enabled() {
|
|
89
89
|
return this.#frame_jitter_enabled;
|