@woosh/meep-engine 2.93.3 → 2.94.1
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 +336 -269
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +336 -269
- 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/collection/heap/Uint32Heap.d.ts.map +1 -1
- package/src/core/collection/heap/Uint32Heap.js +22 -17
- 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/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
- package/src/engine/navigation/grid/find_path_on_grid_astar.js +18 -19
- package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +2 -2
- package/src/engine/ui/GUIEngine.js +1 -1
- 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
|
@@ -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":"find_path_on_grid_astar.d.ts","sourceRoot":"","sources":["../../../../../src/engine/navigation/grid/find_path_on_grid_astar.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find_path_on_grid_astar.d.ts","sourceRoot":"","sources":["../../../../../src/engine/navigation/grid/find_path_on_grid_astar.js"],"names":[],"mappings":"AAkMA;;;;;;;;;;GAUG;AACH,+CATW,MAAM,EAAE,GAAC,UAAU,GAAC,WAAW,GAAC,YAAY,SAC5C,MAAM,UACN,MAAM,SACN,MAAM,QACN,MAAM,oBACN,MAAM,eACN,MAAM,GACJ,MAAO,MAAM,CAAC,CA6F1B"}
|
|
@@ -186,6 +186,12 @@ const open = new Uint32Heap();
|
|
|
186
186
|
const closed = new BitSet();
|
|
187
187
|
closed.preventShrink();
|
|
188
188
|
|
|
189
|
+
/**
|
|
190
|
+
* Contains refined heuristic value
|
|
191
|
+
* @type {Float32Array}
|
|
192
|
+
*/
|
|
193
|
+
let g_score = new Float32Array(1024);
|
|
194
|
+
|
|
189
195
|
/**
|
|
190
196
|
*
|
|
191
197
|
* @param {number[]|Uint8Array|Uint16Array|Float32Array} field
|
|
@@ -218,14 +224,15 @@ export function find_path_on_grid_astar(
|
|
|
218
224
|
open.clear();
|
|
219
225
|
closed.reset();
|
|
220
226
|
|
|
221
|
-
|
|
222
|
-
* Contains refined heuristic value
|
|
223
|
-
* @type {number[]}
|
|
224
|
-
*/
|
|
225
|
-
const g_score = [];
|
|
227
|
+
const cell_count = width * height;
|
|
226
228
|
|
|
227
|
-
g_score
|
|
229
|
+
if (g_score.length < cell_count) {
|
|
230
|
+
g_score = new Float32Array(cell_count);
|
|
231
|
+
}
|
|
228
232
|
|
|
233
|
+
g_score.fill(Infinity, 0, cell_count);
|
|
234
|
+
|
|
235
|
+
g_score[start] = 0;
|
|
229
236
|
|
|
230
237
|
open.insert(start, heuristic(start, goal, width));
|
|
231
238
|
|
|
@@ -269,27 +276,19 @@ export function find_path_on_grid_astar(
|
|
|
269
276
|
// updated path cost
|
|
270
277
|
const cost_so_far = g_score[currentNode] + transition_cost;
|
|
271
278
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const not_in_open_set = index_in_open_set === -1;
|
|
275
|
-
|
|
276
|
-
if (not_in_open_set || cost_so_far < g_score[neighbor]) {
|
|
279
|
+
if (cost_so_far < g_score[neighbor]) {
|
|
277
280
|
|
|
278
|
-
// update
|
|
281
|
+
// update actual cost
|
|
279
282
|
g_score[neighbor] = cost_so_far;
|
|
280
283
|
|
|
281
284
|
const remaining_heuristic = heuristic(neighbor, goal, width);
|
|
282
285
|
|
|
283
286
|
const refined_heuristic = cost_so_far + remaining_heuristic;
|
|
284
287
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
open.insert(neighbor, refined_heuristic);
|
|
288
|
-
} else {
|
|
289
|
-
// Already seen the node, but since it has been re-scored we need to reorder it in the heap
|
|
290
|
-
open.__update_score_by_index(index_in_open_set, refined_heuristic);
|
|
291
|
-
}
|
|
288
|
+
// Pushing to heap will put it in proper place based on the 'f' value.
|
|
289
|
+
open.insert_or_update(neighbor, refined_heuristic)
|
|
292
290
|
}
|
|
291
|
+
|
|
293
292
|
}
|
|
294
293
|
}
|
|
295
294
|
|
|
@@ -36,7 +36,7 @@ test("path on open 3x3 grid", () => {
|
|
|
36
36
|
expect(path).toEqual([0, 3, 5, 8]);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
test("performance, 256x256 random", () => {
|
|
39
|
+
test.skip("performance, 256x256 random", () => {
|
|
40
40
|
const FIELD_SIZE = 256;
|
|
41
41
|
|
|
42
42
|
const field = new Uint8Array(FIELD_SIZE * FIELD_SIZE);
|
|
@@ -52,7 +52,7 @@ test("performance, 256x256 random", () => {
|
|
|
52
52
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const SAMPLE_COUNT =
|
|
55
|
+
const SAMPLE_COUNT = 100000;
|
|
56
56
|
|
|
57
57
|
const coordinates = new Uint32Array(SAMPLE_COUNT * 2);
|
|
58
58
|
|
|
@@ -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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CellFilterUnaryOperation } from "../core/CellFilterUnaryOperation.js";
|
|
2
|
-
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
3
1
|
import { assert } from "../../../core/assert.js";
|
|
2
|
+
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
3
|
+
import { CellFilterUnaryOperation } from "../core/CellFilterUnaryOperation.js";
|
|
4
4
|
|
|
5
5
|
export class CellFilterCache extends CellFilterUnaryOperation {
|
|
6
6
|
|
|
@@ -49,24 +49,24 @@ export class CellFilterCache extends CellFilterUnaryOperation {
|
|
|
49
49
|
|
|
50
50
|
const scale_1 = 1 / this.scale;
|
|
51
51
|
|
|
52
|
-
console.time('Cache filter build');
|
|
52
|
+
// console.time('Cache filter build');
|
|
53
53
|
|
|
54
54
|
let x = 0;
|
|
55
55
|
let y = 0;
|
|
56
56
|
|
|
57
57
|
for (y = 0; y < target_h; y++) {
|
|
58
|
-
const
|
|
58
|
+
const grid_y = y * scale_1;
|
|
59
59
|
|
|
60
60
|
for (x = 0; x < target_w; x++) {
|
|
61
|
-
const
|
|
61
|
+
const grid_x = x * scale_1;
|
|
62
62
|
|
|
63
|
-
const sampleValue = source.execute(grid,
|
|
63
|
+
const sampleValue = source.execute(grid, grid_x, grid_y, 0);
|
|
64
64
|
|
|
65
65
|
cache.writeChannel(x, y, 0, sampleValue);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
console.timeEnd('Cache filter build');
|
|
69
|
+
// console.timeEnd('Cache filter build');
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
execute(grid, x, y, rotation) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellFilterFXAA.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/filtering/numeric/complex/CellFilterFXAA.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CellFilterFXAA.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/filtering/numeric/complex/CellFilterFXAA.js"],"names":[],"mappings":"AAQA;;GAEG;AACH;IAiCI;;;;OAIG;IACH,oBAHW,UAAU,GACR,cAAc,CAY1B;IA7CD;;;OAGG;IACH,QAFU,UAAU,CAEN;IAEd;;;;OAIG;IACH,gBAFU,MAAM,CAEM;IAEtB;;;;;OAKG;IACH,4BAFU,MAAM,CAEkB;IAElC;;;;;OAKG;IACH,wBAFU,MAAM,CAEW;IAoB3B,uCAMC;IAED,0DAwDC;CACJ;2BAxH0B,qBAAqB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { clamp } from "../../../../core/math/clamp.js";
|
|
2
3
|
import { max2 } from "../../../../core/math/max2.js";
|
|
4
|
+
import { max3 } from "../../../../core/math/max3.js";
|
|
3
5
|
import { min2 } from "../../../../core/math/min2.js";
|
|
6
|
+
import { min3 } from "../../../../core/math/min3.js";
|
|
4
7
|
import { CellFilter } from "../../CellFilter.js";
|
|
5
8
|
|
|
6
9
|
/**
|
|
@@ -84,8 +87,8 @@ export class CellFilterFXAA extends CellFilter {
|
|
|
84
87
|
const lumaMaxNeSe = max2(lumaNE, lumaSE);
|
|
85
88
|
const lumaMinNeSe = min2(lumaNE, lumaSE);
|
|
86
89
|
|
|
87
|
-
const lumaMin =
|
|
88
|
-
const lumaMax =
|
|
90
|
+
const lumaMin = min3(lumaM, lumaMinNeSe, lumaMinNwSw);
|
|
91
|
+
const lumaMax = max3(lumaM, lumaMaxNeSe, lumaMaxNwSw);
|
|
89
92
|
|
|
90
93
|
if (lumaMin === lumaMax) {
|
|
91
94
|
//no luma difference across the sampled region
|
|
@@ -97,13 +100,13 @@ export class CellFilterFXAA extends CellFilter {
|
|
|
97
100
|
|
|
98
101
|
const dirReduce = max2(
|
|
99
102
|
(lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * this.edge_threshold),
|
|
100
|
-
this.console_edge_threshold_min
|
|
103
|
+
this.console_edge_threshold_min
|
|
104
|
+
);
|
|
101
105
|
|
|
102
106
|
const rcpDirMin = 1.0 / (min2(Math.abs(dir_x), Math.abs(dir_y)) + dirReduce);
|
|
103
107
|
|
|
104
|
-
const dir1_x =
|
|
105
|
-
const dir1_y =
|
|
106
|
-
|
|
108
|
+
const dir1_x = clamp(dir_x * rcpDirMin, -this.console_edge_sharpness, this.console_edge_sharpness);
|
|
109
|
+
const dir1_y = clamp(dir_y * rcpDirMin, -this.console_edge_sharpness, this.console_edge_sharpness);
|
|
107
110
|
|
|
108
111
|
const valueN1 = this.source.execute(grid, x + dir1_x * (1 / 3 - 0.5), y + dir1_y * (1 / 3 - 0.5), rotation);
|
|
109
112
|
const valueP1 = this.source.execute(grid, x + dir1_x * (2 / 3 - 0.5), y + dir1_y * (2 / 3 - 0.5), rotation);
|
|
@@ -21,22 +21,10 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
21
21
|
size_y: number;
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
|
-
* @type {
|
|
24
|
+
* @type {Float32Array}
|
|
25
25
|
* @private
|
|
26
26
|
*/
|
|
27
27
|
private __kernel;
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @type {number}
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
private __kernel_total_power;
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @type {number}
|
|
37
|
-
* @private
|
|
38
|
-
*/
|
|
39
|
-
private __inv_kernel_total_power;
|
|
40
28
|
/**
|
|
41
29
|
* Written by 'initialize' stage
|
|
42
30
|
* @type {number}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellFilterGaussianBlur.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CellFilterGaussianBlur.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js"],"names":[],"mappings":"AAMA;IA+DI;;;;;;;OAOG;IACH,oBANW,UAAU,KACV,MAAM,KACN,MAAM,YACN,MAAM,GACJ,sBAAsB,CAkBlC;IAtFD,kBAAc;IACd,kBAAc;IAEd,gBAAa;IACb,gBAAa;IAEb;;;OAGG;IACH,QAFU,UAAU,CAEN;IAEd,eAAW;IACX,eAAW;IAEX;;;;OAIG;IACH,iBAA+B;IAE/B;;;;OAIG;IACH,wBAAoB;IAEpB;;;;OAIG;IACH,wBAAoB;IAEpB,uCAuBC;IA6BD,0DA4CC;CACJ;2BAxI0B,qBAAqB"}
|