@woosh/meep-engine 2.93.3 → 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 +295 -232
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +295 -232
- 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/curve/prototypeGLTF.js +4 -1
- 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,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;
|
|
@@ -7,21 +7,22 @@ import {
|
|
|
7
7
|
PerspectiveCamera,
|
|
8
8
|
PlaneBufferGeometry,
|
|
9
9
|
Scene,
|
|
10
|
-
Vector2,
|
|
11
10
|
WebGLRenderer
|
|
12
11
|
} from "three";
|
|
13
12
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
13
|
+
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
14
|
+
import "../../../../../../../../css/main.scss";
|
|
14
15
|
import Signal from "../../../../core/events/signal/Signal.js";
|
|
16
|
+
import { computePathDirectory } from "../../../../core/path/computePathDirectory.js";
|
|
17
|
+
import LabelView from "../../../../view/common/LabelView.js";
|
|
15
18
|
import { CSS_ABSOLUTE_POSITIONING } from "../../../../view/CSS_ABSOLUTE_POSITIONING.js";
|
|
16
19
|
import EmptyView from "../../../../view/elements/EmptyView.js";
|
|
20
|
+
import SmoothProgressBar from "../../../../view/elements/progress/SmoothProgressBar.js";
|
|
17
21
|
import { AssetManager } from "../../../asset/AssetManager.js";
|
|
18
22
|
import { GameAssetType } from "../../../asset/GameAssetType.js";
|
|
19
23
|
import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
20
24
|
import { buildCanvasViewFromTexture } from "../../render/visibility/hiz/buildCanvasViewFromTexture.js";
|
|
21
|
-
import {
|
|
22
|
-
import { VirtualTextureMemoryMapping } from "./VirtualTextureMemoryMapping.js";
|
|
23
|
-
import { VirtualTexturePage } from "./VirtualTexturePage.js";
|
|
24
|
-
import { VirtualTextureUsageUpdater } from "./VirtualTextureUsageUpdater.js";
|
|
25
|
+
import { VirtualTextureSystem } from "./VirtualTextureSystem.js";
|
|
25
26
|
|
|
26
27
|
let camera,
|
|
27
28
|
/**
|
|
@@ -45,18 +46,13 @@ const signal_render = new Signal();
|
|
|
45
46
|
// const TEXTURE_URL = "data/textures/utility/TESTIMAGES/SAMPLING/8BIT/RGB/2448x2448/SRC/img_2448x2448_3x8bit_SRC_RGB_cards_a.png";
|
|
46
47
|
// const TEXTURE_URL = "data/models/LowPolyTownshipSet/Town_Hall//diffuse_2048.png";
|
|
47
48
|
|
|
48
|
-
const virtualTextureManager = new VirtualTextureUsageUpdater();
|
|
49
|
-
const virtualTexturePage = new VirtualTexturePage();
|
|
50
|
-
// const residencyDebugView = new ResidencyDebugView({ scale: 1 });
|
|
51
|
-
const memoryMapping = new VirtualTextureMemoryMapping();
|
|
52
|
-
|
|
53
49
|
|
|
54
50
|
// const usageDebugView = new UsageDebugView();
|
|
55
51
|
// usageDebugView.position.set(0,256);
|
|
56
|
-
|
|
57
|
-
window.page = virtualTexturePage;
|
|
58
|
-
window.mapping = memoryMapping;
|
|
59
|
-
window.usage = virtualTextureManager.usage_metadata;
|
|
52
|
+
//
|
|
53
|
+
// window.page = virtualTexturePage;
|
|
54
|
+
// window.mapping = memoryMapping;
|
|
55
|
+
// window.usage = virtualTextureManager.usage_metadata;
|
|
60
56
|
|
|
61
57
|
const container_view = new EmptyView();
|
|
62
58
|
|
|
@@ -95,25 +91,125 @@ function makeMesh(mat) {
|
|
|
95
91
|
return mesh;
|
|
96
92
|
}
|
|
97
93
|
|
|
98
|
-
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @type {VirtualTextureSystem[]}
|
|
97
|
+
*/
|
|
98
|
+
const virtual_texture_managers = [];
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
async function loadGLTF({
|
|
101
|
+
path
|
|
102
|
+
}) {
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
const loader = new GLTFLoader();
|
|
105
|
+
|
|
106
|
+
const base_path = computePathDirectory(path);
|
|
107
|
+
|
|
108
|
+
const progress = new SmoothProgressBar();
|
|
109
|
+
|
|
110
|
+
function layout() {
|
|
111
|
+
progress.size.set(100, 20);
|
|
112
|
+
progress.position.set((container_view.size.x - progress.size.x) * 0.5, (container_view.size.y - progress.size.y) * 0.5);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
layout();
|
|
116
|
+
container_view.size.onChanged.add(layout);
|
|
117
|
+
|
|
118
|
+
container_view.addChild(progress);
|
|
119
|
+
|
|
120
|
+
const gltf = await new Promise((resolve, reject) => {
|
|
121
|
+
|
|
122
|
+
loader.load(path, resolve, event => {
|
|
123
|
+
console.log(event);
|
|
124
|
+
|
|
125
|
+
progress.max = event.total;
|
|
126
|
+
progress.value = event.loaded;
|
|
127
|
+
}, reject);
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
container_view.removeChild(progress);
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
console.warn(gltf);
|
|
134
|
+
|
|
135
|
+
const materials = new Set();
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
* @type {Map<Material, Mesh[]>}
|
|
140
|
+
*/
|
|
141
|
+
const material_users = new Map();
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
*
|
|
145
|
+
* @type {Map<Material, Material>}
|
|
146
|
+
*/
|
|
147
|
+
const replacement_materials = new Map();
|
|
148
|
+
|
|
149
|
+
gltf.scene.traverse(n => {
|
|
150
|
+
if (!n.isMesh) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const mat = n.material;
|
|
155
|
+
if (mat === undefined) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (materials.has(mat)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const extensionVT = mat.userData?.gltfExtensions?.meepVirtualTexture;
|
|
164
|
+
if (extensionVT === undefined) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
materials.add(mat);
|
|
169
|
+
|
|
170
|
+
const vts = {};
|
|
171
|
+
|
|
172
|
+
for (const textureKey in extensionVT) {
|
|
173
|
+
const textureMeta = extensionVT[textureKey];
|
|
174
|
+
|
|
175
|
+
const vt = new VirtualTextureSystem();
|
|
176
|
+
|
|
177
|
+
vt.setTexture({
|
|
178
|
+
path: base_path + '/' + textureMeta.path,
|
|
179
|
+
texture_resolution: textureMeta.texture_resolution,
|
|
180
|
+
tile_resolution: textureMeta.tile_size,
|
|
181
|
+
tile_margin: textureMeta.tile_margin
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
virtual_texture_managers.push(vt);
|
|
185
|
+
|
|
186
|
+
vts[textureKey] = vt;
|
|
187
|
+
}
|
|
115
188
|
|
|
116
|
-
|
|
189
|
+
if (vts.baseColorTexture !== undefined) {
|
|
190
|
+
replacement_materials.set(mat, vts.baseColorTexture.makeMaterial())
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
// replace materials
|
|
195
|
+
gltf.scene.traverse(n => {
|
|
196
|
+
if (n.isMesh) {
|
|
197
|
+
|
|
198
|
+
const replacement = replacement_materials.get(n.material);
|
|
199
|
+
|
|
200
|
+
if (replacement !== undefined) {
|
|
201
|
+
n.material = replacement;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
return gltf.scene;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function flatSample({
|
|
211
|
+
am
|
|
212
|
+
}) {
|
|
117
213
|
|
|
118
214
|
// virtualTexturePage.path = "data/textures/utility/maurus_uv_checker_8k/vt-01-32";
|
|
119
215
|
// virtualTexturePage.path = "data/textures/utility/maurus_uv_checker_8k/vt-01-128";
|
|
@@ -121,25 +217,63 @@ async function init() {
|
|
|
121
217
|
// virtualTexturePage.path = "data/textures/utility/aco-greece/vt-01-128";
|
|
122
218
|
// sparseTexture.path = "data/textures/utility/vt/uv_map_reference";
|
|
123
219
|
// virtualTexturePage.path = "data/textures/utility/vt/Lenna";
|
|
124
|
-
virtualTexturePage.path = "data/textures/utility/Lenna/vt-01-32";
|
|
220
|
+
// virtualTexturePage.path = "data/textures/utility/Lenna/vt-01-32";
|
|
125
221
|
// sparseTexture.path = "data/textures/utility/vt/TexelDensity1";
|
|
126
|
-
// virtualTexturePage.page_texture_size = [32, 64];
|
|
127
|
-
// virtualTexturePage.page_texture_size = [256, 256];
|
|
128
|
-
// virtualTexturePage.page_texture_size = [280, 280];
|
|
129
|
-
// virtualTexturePage.page_texture_size = [256,512];
|
|
130
|
-
virtualTexturePage.page_texture_size = [512, 512];
|
|
131
|
-
// virtualTexturePage.page_texture_size = [480, 480];
|
|
132
|
-
// virtualTexturePage.page_texture_size = [384, 1280];
|
|
133
|
-
// virtualTexturePage.page_texture_size = [1024, 1024];
|
|
134
|
-
// virtualTexturePage.page_texture_size = [2048, 2048];
|
|
135
|
-
// virtualTexturePage.page_texture_size = [4096, 4096];
|
|
136
|
-
virtualTexturePage.asset_manager = am;
|
|
137
222
|
|
|
138
|
-
|
|
223
|
+
const vts = new VirtualTextureSystem();
|
|
224
|
+
|
|
225
|
+
vts.setTexture({
|
|
226
|
+
path: "data/textures/utility/Lenna/vt-01-32",
|
|
227
|
+
texture_resolution: 512,
|
|
228
|
+
tile_resolution: 32,
|
|
229
|
+
});
|
|
230
|
+
vts.initialize({
|
|
231
|
+
asset_manager: am,
|
|
232
|
+
// page_resolution: 1024
|
|
233
|
+
})
|
|
234
|
+
// console.log(virtualTexturePage);
|
|
235
|
+
|
|
236
|
+
const material = vts.makeMaterial();
|
|
139
237
|
|
|
238
|
+
console.log(material.uniforms);
|
|
239
|
+
|
|
240
|
+
const virt = makeMesh(material);
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
virtual_texture_managers.push(vts);
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function init() {
|
|
248
|
+
|
|
249
|
+
const am = new AssetManager();
|
|
250
|
+
await am.registerLoader(GameAssetType.Image, new ImageRGBADataLoader());
|
|
251
|
+
am.startup();
|
|
252
|
+
|
|
253
|
+
const container = document.body;
|
|
254
|
+
|
|
255
|
+
container.style.margin = "0";
|
|
256
|
+
|
|
257
|
+
container.appendChild(container_view.el);
|
|
258
|
+
container_view.link();
|
|
259
|
+
|
|
260
|
+
scene = new Scene();
|
|
261
|
+
|
|
262
|
+
const gltf = await loadGLTF({ path: "data/models/Scans/green_car_wreck/converted/model.gltf" })
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
virtual_texture_managers.forEach(vt => {
|
|
266
|
+
vt.initialize({
|
|
267
|
+
asset_manager: am,
|
|
268
|
+
page_resolution: 4096
|
|
269
|
+
})
|
|
270
|
+
});
|
|
140
271
|
|
|
141
|
-
console.log(
|
|
272
|
+
console.log(virtual_texture_managers);
|
|
142
273
|
|
|
274
|
+
const manager = virtual_texture_managers[0];
|
|
275
|
+
|
|
276
|
+
scene.add(gltf);
|
|
143
277
|
|
|
144
278
|
//
|
|
145
279
|
// usageDebugView.mip_levels = virtualTextureManager.max_mip_level;
|
|
@@ -147,29 +281,41 @@ async function init() {
|
|
|
147
281
|
|
|
148
282
|
|
|
149
283
|
// const usagePyramidDebugView = new UsagePyramidDebugView();
|
|
150
|
-
// usagePyramidDebugView.setImageURL(
|
|
284
|
+
// usagePyramidDebugView.setImageURL("data/models/Scans/green_car_wreck/converted/merged_1024.png");
|
|
151
285
|
// container_view.addChild(usagePyramidDebugView);
|
|
286
|
+
//
|
|
287
|
+
// signal_render.add(()=>{
|
|
288
|
+
//
|
|
289
|
+
// usagePyramidDebugView.setTextureParameters(manager.updater.texture_resolution, manager.updater.tile_resolution);
|
|
290
|
+
// usagePyramidDebugView.usage = manager.updater.usage_metadata;
|
|
291
|
+
// })
|
|
152
292
|
|
|
153
|
-
// residencyDebugView
|
|
293
|
+
// const residencyDebugView = new ResidencyDebugView();
|
|
294
|
+
// residencyDebugView.texture = manager.page;
|
|
154
295
|
// residencyDebugView.css({
|
|
155
296
|
// bottom: 0,
|
|
156
297
|
// right: 0
|
|
157
298
|
// });
|
|
158
299
|
// container_view.addChild(residencyDebugView);
|
|
300
|
+
//
|
|
301
|
+
// signal_render.add(()=> residencyDebugView.update());
|
|
159
302
|
|
|
160
303
|
// ===================
|
|
161
304
|
|
|
162
|
-
const container = document.body;
|
|
163
|
-
|
|
164
|
-
container.style.margin = "0";
|
|
165
|
-
|
|
166
|
-
container.appendChild(container_view.el);
|
|
167
|
-
container_view.link();
|
|
168
305
|
|
|
169
306
|
camera = new PerspectiveCamera(35, window.innerWidth / window.innerHeight, 0.1, 100);
|
|
170
|
-
camera.position.
|
|
307
|
+
camera.position.set(
|
|
308
|
+
12.022084899129627,
|
|
309
|
+
9.60952583639588,
|
|
310
|
+
-0.04984304693423923
|
|
311
|
+
);
|
|
312
|
+
camera.rotation.set(
|
|
313
|
+
-1.5687013871667483,
|
|
314
|
+
0.9201500864954011,
|
|
315
|
+
1.5681634783563936);
|
|
316
|
+
|
|
317
|
+
window.camera = camera;
|
|
171
318
|
|
|
172
|
-
scene = new Scene();
|
|
173
319
|
// scene.background = new Color("#002D62");
|
|
174
320
|
|
|
175
321
|
clock = new Clock();
|
|
@@ -183,15 +329,8 @@ async function init() {
|
|
|
183
329
|
// side: DoubleSide
|
|
184
330
|
// });
|
|
185
331
|
|
|
186
|
-
const material = new VirtualTextureMaterial({
|
|
187
|
-
page: virtualTexturePage,
|
|
188
|
-
mapping: memoryMapping
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
console.log(material.uniforms);
|
|
192
332
|
|
|
193
333
|
// makeTorus();
|
|
194
|
-
const virt = makeMesh(material);
|
|
195
334
|
// virt.position.x = -0.4
|
|
196
335
|
|
|
197
336
|
// const original_texture = new TextureLoader().load("data/textures/utility/maurus_uv_checker_8k/UV-CheckerMap_Maurus_01_8K.png");
|
|
@@ -216,7 +355,7 @@ async function init() {
|
|
|
216
355
|
//
|
|
217
356
|
|
|
218
357
|
renderer = new WebGLRenderer({ antialias: true });
|
|
219
|
-
renderer.setClearColor("#002D62",1);
|
|
358
|
+
renderer.setClearColor("#002D62", 1);
|
|
220
359
|
|
|
221
360
|
renderer.setPixelRatio(window.devicePixelRatio);
|
|
222
361
|
container.appendChild(renderer.domElement);
|
|
@@ -242,13 +381,12 @@ async function init() {
|
|
|
242
381
|
// gui.add(options, key);
|
|
243
382
|
// });
|
|
244
383
|
|
|
245
|
-
virtualTexturePage.renderer = renderer;
|
|
246
|
-
|
|
247
384
|
|
|
248
385
|
animate();
|
|
249
386
|
|
|
387
|
+
|
|
250
388
|
const mappingPreview = buildCanvasViewFromTexture({
|
|
251
|
-
texture:
|
|
389
|
+
texture: manager.page.texture,
|
|
252
390
|
renderer,
|
|
253
391
|
swizzle: ['r', 'g', 'b', 1],
|
|
254
392
|
width: 256,
|
|
@@ -259,15 +397,29 @@ async function init() {
|
|
|
259
397
|
mappingPreview.view.css(CSS_ABSOLUTE_POSITIONING);
|
|
260
398
|
mappingPreview.view.css({
|
|
261
399
|
// border: "1px solid red"
|
|
262
|
-
boxShadow: "0 0 8px rgba(0,0,0,0.4)"
|
|
400
|
+
boxShadow: "0 0 8px rgba(0,0,0,0.4)",
|
|
263
401
|
});
|
|
264
|
-
mappingPreview.view.position.set(
|
|
402
|
+
mappingPreview.view.position.set(4, 4);
|
|
403
|
+
|
|
265
404
|
|
|
266
405
|
signal_render.add(() => {
|
|
267
406
|
mappingPreview.render();
|
|
268
407
|
});
|
|
269
408
|
|
|
270
409
|
container_view.addChild(mappingPreview.view);
|
|
410
|
+
|
|
411
|
+
// credits
|
|
412
|
+
container_view.addChild(new LabelView(`MODEL: Green car wreck, by matousekfoto, CC-BY-4.0`, {
|
|
413
|
+
css: {
|
|
414
|
+
position: "absolute",
|
|
415
|
+
bottom: "4px",
|
|
416
|
+
width: "100%",
|
|
417
|
+
textAlign: "center",
|
|
418
|
+
color: "#88e1d2",
|
|
419
|
+
textShadow: "0 0 3px black",
|
|
420
|
+
fontFamily: "monospace"
|
|
421
|
+
}
|
|
422
|
+
}));
|
|
271
423
|
}
|
|
272
424
|
|
|
273
425
|
function onWindowResize() {
|
|
@@ -292,20 +444,13 @@ function animate() {
|
|
|
292
444
|
function render() {
|
|
293
445
|
|
|
294
446
|
const delta = 5 * clock.getDelta();
|
|
295
|
-
|
|
447
|
+
|
|
296
448
|
// if (options.spin && mesh !== undefined) {
|
|
297
449
|
// mesh.rotation.y += 0.0125 * delta;
|
|
298
450
|
// mesh.rotation.x += 0.05 * delta;
|
|
299
451
|
// }
|
|
300
452
|
|
|
301
|
-
|
|
302
|
-
view_port_size.multiplyScalar(renderer.getPixelRatio());
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
virtualTextureManager.setViewportResolution(view_port_size.x, view_port_size.y);
|
|
306
|
-
virtualTextureManager.updateUsage(renderer, scene, camera);
|
|
307
|
-
virtualTexturePage.update_usage(virtualTextureManager.usage_metadata);
|
|
308
|
-
memoryMapping.residency = virtualTexturePage;
|
|
453
|
+
virtual_texture_managers.forEach(vts => vts.update(renderer, scene, camera));
|
|
309
454
|
|
|
310
455
|
// renderer.setViewport(0, 0, view_port_size.x, view_port_size.y);
|
|
311
456
|
renderer.clear();
|
|
@@ -313,9 +458,6 @@ function render() {
|
|
|
313
458
|
|
|
314
459
|
// usageDebugView.usage = virtualTextureManager.usage_metadata;
|
|
315
460
|
|
|
316
|
-
// usagePyramidDebugView.setTextureParameters(virtualTextureManager.texture_resolution, virtualTextureManager.tile_resolution);
|
|
317
|
-
// usagePyramidDebugView.usage = virtualTextureManager.usage_metadata;
|
|
318
|
-
|
|
319
461
|
// residencyDebugView.update();
|
|
320
462
|
|
|
321
463
|
signal_render.send0();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellFilterCache.d.ts","sourceRoot":"","sources":["../../../../../src/generation/filtering/numeric/CellFilterCache.js"],"names":[],"mappings":"AAIA;IAeI;;;;;OAKG;IACH,wCAHW,MAAM,GACJ,eAAe,CAU3B;IA3BD;;;;OAIG;IACH,gBAAqC;IAErC;;;OAGG;IACH,OAFU,MAAM,CAEN;CAyDb;
|
|
1
|
+
{"version":3,"file":"CellFilterCache.d.ts","sourceRoot":"","sources":["../../../../../src/generation/filtering/numeric/CellFilterCache.js"],"names":[],"mappings":"AAIA;IAeI;;;;;OAKG;IACH,wCAHW,MAAM,GACJ,eAAe,CAU3B;IA3BD;;;;OAIG;IACH,gBAAqC;IAErC;;;OAGG;IACH,OAFU,MAAM,CAEN;CAyDb;yCAxEwC,qCAAqC"}
|