@woosh/meep-engine 2.42.7 → 2.43.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/core/binary/BitSet.js +4 -4
- package/core/binary/ctz32.js +40 -0
- package/core/collection/ObservedMap.js +61 -57
- package/core/collection/heap/FastBinaryHeap.js +7 -1
- package/core/collection/heap/Uint32Heap.js +19 -0
- package/core/collection/map/AsyncLoadingCache.js +3 -1
- package/core/geom/2d/compute_polygon_area_2d.js +32 -0
- package/core/geom/2d/compute_polygon_area_2d.spec.js +10 -0
- package/core/geom/2d/compute_triangle_area_2d.js +15 -0
- package/core/geom/2d/compute_triangle_area_2d.spec.js +9 -0
- package/core/geom/2d/convex-hull/convex_hull_jarvis_2d.js +64 -0
- package/core/geom/2d/convex-hull/convex_hull_jarvis_2d.spec.js +33 -0
- package/core/geom/2d/convex-hull/convex_hull_monotone_2d.js +82 -0
- package/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +135 -0
- package/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +282 -0
- package/core/geom/2d/convex-hull/orientation3.js +444 -0
- package/core/geom/2d/convex-hull/orientation3_array.js +22 -0
- package/core/geom/2d/convex-hull/orientation3_v2.js +12 -0
- package/core/geom/2d/intersect_ray_2d.js +56 -0
- package/core/geom/2d/quad-tree/QuadTreeNode.js +0 -81
- package/core/geom/2d/quad-tree/qt_match_data_by_circle.js +70 -0
- package/core/geom/3d/matrix/m4_multiply_alphatensor.js +131 -0
- package/core/geom/3d/plane/orient3d_fast.js +2 -6
- package/core/geom/3d/tetrahedra/README.md +7 -0
- package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +3 -1
- package/core/geom/3d/tetrahedra/delaunay/Cavity.js +48 -0
- package/core/geom/3d/tetrahedra/{compute_delaunay_tetrahedral_mesh.js → delaunay/compute_delaunay_tetrahedral_mesh.js} +15 -7
- package/core/geom/3d/tetrahedra/{compute_delaunay_tetrahedral_mesh.spec.js → delaunay/compute_delaunay_tetrahedral_mesh.spec.js} +0 -0
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity.js +73 -0
- package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_toward_cavity.js +48 -0
- package/core/geom/3d/tetrahedra/hxt/a.js +524 -0
- package/core/geom/3d/tetrahedra/hxt/hxt.js +140 -0
- package/core/geom/3d/tetrahedra/hxt/hxt.wasm +0 -0
- package/core/geom/3d/tetrahedra/point_in_tetrahedron_circumsphere.js +35 -20
- package/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +98 -0
- package/core/geom/3d/tetrahedra/tetrahedra_collection.js +60 -131
- package/core/geom/packing/{MaxRectangles.js → max-rect/MaxRectangles.js} +28 -124
- package/core/geom/packing/max-rect/removeRedundantBoxes.js +69 -0
- package/core/geom/packing/max-rect/removeRedundantBoxesArray.js +40 -0
- package/core/geom/v3_distance_above_plane.js +1 -1
- package/core/graph/layout/BoxLayouter.js +2 -88
- package/core/graph/layout/CircleLayout.js +2 -1
- package/core/graph/layout/box/forceIntoBox.js +45 -0
- package/core/graph/layout/box/pullBoxTowardsPoint.js +20 -0
- package/core/graph/layout/box/resolveAABB2Overlap.js +22 -0
- package/core/math/bessel_3.js +11 -0
- package/core/math/bessel_i0.js +26 -0
- package/core/process/executor/ConcurrentExecutor.spec.js +2 -1
- package/core/process/task/util/actionTask.js +19 -0
- package/core/process/task/util/countTask.js +62 -0
- package/core/process/task/util/delayTask.js +45 -0
- package/core/process/task/util/emptyTask.js +19 -0
- package/core/process/task/util/failingTask.js +17 -0
- package/core/process/task/util/futureTask.js +48 -0
- package/core/process/task/util/promiseTask.js +42 -0
- package/core/process/task/util/randomCountTask.js +64 -0
- package/core/process/task/util/wrapTaskIgnoreFailure.js +47 -0
- package/engine/Engine.js +8 -8
- package/engine/EngineBootstrapper.js +1 -1
- package/engine/asset/AssetManager.js +197 -53
- package/engine/asset/AssetRequest.js +32 -0
- package/engine/asset/loaders/ArrayBufferLoader.js +62 -50
- package/engine/asset/loaders/image/png/PNG.js +15 -1
- package/engine/asset/loaders/image/png/PNGReader.js +3 -2
- package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +2 -1
- package/engine/ecs/storage/BinaryBufferDeSerializer.js +1 -1
- package/engine/ecs/storage/JSONDeSerializer.js +2 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapOptimizer.js +2 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
- package/engine/graphics/camera/makeScreenScissorFrustum.js +1 -1
- package/engine/graphics/camera/testClippingPlaneComputation.js +4 -45
- package/engine/graphics/ecs/camera/FrustumProjector.js +6 -0
- package/engine/graphics/ecs/decal/v2/FPDecalSystem.js +5 -0
- package/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +23 -4
- package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +1 -1
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +11 -0
- package/engine/graphics/geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js +1 -2
- package/engine/graphics/impostors/octahedral/ImpostorBaker.js +5 -2
- package/engine/graphics/impostors/octahedral/ImpostorDescription.js +18 -0
- package/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +15 -0
- package/engine/graphics/impostors/octahedral/prototypeBaker.js +66 -79
- package/engine/graphics/impostors/octahedral/shader/ImpostorShaderWireframeV0.js +134 -0
- package/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +128 -0
- package/engine/graphics/impostors/octahedral/util/build_geometry_from_cutout_shape.js +32 -0
- package/engine/graphics/impostors/octahedral/util/load_mesh_for_bake.js +31 -0
- package/engine/graphics/impostors/octahedral/util/makeImpostorAtlasPreview.js +107 -0
- package/engine/graphics/material/manager/ManagedMaterial.js +4 -0
- package/engine/graphics/material/manager/MaterialManager.js +1 -0
- package/engine/graphics/material/optimization/MaterialOptimizationContext.js +7 -3
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +2 -2
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +0 -19
- package/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
- package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +83 -27
- package/engine/graphics/shadows/ShadowMapRenderer.js +11 -4
- package/engine/graphics/texture/atlas/AbstractTextureAtlas.js +2 -1
- package/engine/graphics/texture/atlas/CachingTextureAtlas.js +208 -38
- package/engine/graphics/texture/atlas/TextureAtlas.js +31 -24
- package/engine/graphics/texture/atlas/gpu/WebGLTextureAtlas.js +1 -1
- package/engine/graphics/texture/sampler/filter/box.js +16 -0
- package/engine/graphics/texture/sampler/filter/cubic2.js +32 -0
- package/engine/graphics/texture/sampler/filter/gaussian.js +16 -0
- package/engine/graphics/texture/sampler/filter/kaiser_1.js +19 -0
- package/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +19 -0
- package/engine/graphics/texture/sampler/filter/mitchell.js +55 -0
- package/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +109 -0
- package/engine/graphics/texture/sampler/filter/triangle.js +19 -0
- package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +187 -86
- package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +77 -25
- package/engine/graphics/texture/sampler/search/make_edge_condition_channel_threshold.js +34 -0
- package/engine/graphics/texture/sampler/search/sampler2d_find_pixels.js +24 -0
- package/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +212 -0
- package/engine/knowledge/database/StaticKnowledgeDataTable.js +1 -1
- package/engine/navigation/grid/AStar.js +1 -1
- package/engine/plugin/EnginePluginManager.js +28 -27
- package/engine/plugin/PluginReferenceContext.js +9 -0
- package/engine/scene/Scene.js +1 -1
- package/engine/scene/SerializedScene.js +1 -1
- package/engine/scene/transitionToScene.js +3 -1
- package/generation/example/main.js +1 -1
- package/generation/grid/generation/GridTaskApplyActionToCells.js +1 -1
- package/generation/grid/generation/GridTaskDensityMarkerDistribution.js +1 -1
- package/generation/grid/generation/GridTaskExecuteRuleTimes.js +1 -1
- package/generation/grid/generation/NoopGridTaskGenerator.js +1 -1
- package/generation/grid/generation/discrete/GridTaskCellularAutomata.js +2 -1
- package/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
- package/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +3 -2
- package/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +1 -1
- package/generation/grid/generation/grid/GridTaskAddNodesFixed.js +1 -1
- package/generation/grid/generation/road/GridTaskGenerateRoads.js +3 -2
- package/generation/grid/generation/util/buildDistanceMapToObjective.js +1 -1
- package/generation/markers/GridActionRuleSet.js +2 -1
- package/generation/placement/GridCellActionTransformNearbyMarkers.js +2 -4
- package/generation/theme/ThemeEngine.js +4 -1
- package/package.json +1 -1
- package/view/asset/AssetLoaderStatusView.js +5 -5
- package/view/minimap/gl/MinimapTerrainGL.js +1 -2
- package/view/renderModel.js +1 -1
- package/view/tooltip/TooltipView.js +5 -5
- package/core/process/task/TaskUtils.js +0 -352
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import { renderSamplerFromTexture } from "../../../render/visibility/hiz/buildCanvasViewFromTexture.js";
|
|
4
|
+
import { convex_hull_jarvis_2d } from "../../../../../core/geom/2d/convex-hull/convex_hull_jarvis_2d.js";
|
|
5
|
+
import { fixed_convex_hull_relaxation } from "../../../../../core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js";
|
|
6
|
+
import { array_copy } from "../../../../../core/collection/array/copyArray.js";
|
|
7
|
+
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
8
|
+
import { max2 } from "../../../../../core/math/max2.js";
|
|
9
|
+
import { sampler2d_find_pixels } from "../../../texture/sampler/search/sampler2d_find_pixels.js";
|
|
10
|
+
import {
|
|
11
|
+
make_edge_condition_channel_threshold
|
|
12
|
+
} from "../../../texture/sampler/search/make_edge_condition_channel_threshold.js";
|
|
13
|
+
import { compute_polygon_area_2d } from "../../../../../core/geom/2d/compute_polygon_area_2d.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* TODO For this specific use-case with octahedral impostors we can get away tracing a circular shape in general.
|
|
17
|
+
* A circle is a lot easier to quantize (as long as we make sure we place edges outside of the circle)
|
|
18
|
+
* @param {ImpostorDescription} impostor
|
|
19
|
+
* @param {THREE.WebGLRenderer} renderer
|
|
20
|
+
* @returns {number}
|
|
21
|
+
*/
|
|
22
|
+
export function build_cutout_from_atlas_by_alpha(impostor, renderer) {
|
|
23
|
+
// get impostor data first
|
|
24
|
+
|
|
25
|
+
const ctrl = renderSamplerFromTexture({
|
|
26
|
+
renderer: renderer,
|
|
27
|
+
// swizzle: ['a', 'a', 'a', 1],
|
|
28
|
+
swizzle: ['a', 'a', 'a', 1],
|
|
29
|
+
texture: impostor.rt.texture[0]
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
ctrl.render();
|
|
33
|
+
|
|
34
|
+
const source_canvas_data = ctrl.destination.data;
|
|
35
|
+
|
|
36
|
+
// build set of border pixels
|
|
37
|
+
const frame_size = impostor.resolution / impostor.frame_count;
|
|
38
|
+
const frame_size_i = Math.ceil(frame_size);
|
|
39
|
+
|
|
40
|
+
const accummulator = Sampler2D.uint8(1, frame_size_i, frame_size_i);
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < impostor.frame_count; i++) {
|
|
43
|
+
|
|
44
|
+
const frame_offset_y = Math.floor(frame_size * i);
|
|
45
|
+
|
|
46
|
+
for (let j = 0; j < impostor.frame_count; j++) {
|
|
47
|
+
|
|
48
|
+
const frame_offset_x = Math.floor(frame_size * j);
|
|
49
|
+
|
|
50
|
+
for (let y = 0; y < frame_size_i; y++) {
|
|
51
|
+
const global_y = frame_offset_y + y;
|
|
52
|
+
|
|
53
|
+
for (let x = 0; x < frame_size_i; x++) {
|
|
54
|
+
|
|
55
|
+
const global_x = x + frame_offset_x;
|
|
56
|
+
|
|
57
|
+
const global_index = global_y * impostor.resolution + global_x;
|
|
58
|
+
|
|
59
|
+
const v = source_canvas_data[global_index * 4];
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if (v > 0) {
|
|
63
|
+
|
|
64
|
+
const local_index = y * frame_size_i + x;
|
|
65
|
+
|
|
66
|
+
accummulator.data[local_index] = max2(v, accummulator.data[local_index]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
const edge_pixels = sampler2d_find_pixels(accummulator, make_edge_condition_channel_threshold(0, 5));
|
|
75
|
+
|
|
76
|
+
// filtered pixels
|
|
77
|
+
const filtered_edge_pixels = [];
|
|
78
|
+
|
|
79
|
+
const half_pixel = 0.5;
|
|
80
|
+
|
|
81
|
+
for (let i = 0; i < edge_pixels.length; i += 2) {
|
|
82
|
+
const x = edge_pixels[i];
|
|
83
|
+
const y = edge_pixels[i + 1];
|
|
84
|
+
|
|
85
|
+
filtered_edge_pixels.push(x - half_pixel, y - half_pixel);
|
|
86
|
+
filtered_edge_pixels.push(x + half_pixel, y - half_pixel);
|
|
87
|
+
filtered_edge_pixels.push(x + half_pixel, y + half_pixel);
|
|
88
|
+
filtered_edge_pixels.push(x - half_pixel, y + half_pixel);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const hull_point_indices = convex_hull_jarvis_2d(filtered_edge_pixels, filtered_edge_pixels.length / 2);
|
|
92
|
+
|
|
93
|
+
const hull_points = [];
|
|
94
|
+
|
|
95
|
+
for (let i = 0; i < hull_point_indices.length; i++) {
|
|
96
|
+
const hpi = hull_point_indices[i];
|
|
97
|
+
|
|
98
|
+
array_copy(filtered_edge_pixels, hpi * 2, hull_points, i * 2, 2);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const cutout_vertex_count = 8;
|
|
102
|
+
|
|
103
|
+
const cutout_points = new Float32Array(cutout_vertex_count * 2);
|
|
104
|
+
|
|
105
|
+
fixed_convex_hull_relaxation(cutout_points, 0, cutout_vertex_count, hull_points, hull_point_indices.length);
|
|
106
|
+
|
|
107
|
+
// normalize points
|
|
108
|
+
for (let i = 0; i < cutout_vertex_count; i++) {
|
|
109
|
+
cutout_points[i * 2] /= frame_size;
|
|
110
|
+
cutout_points[i * 2 + 1] /= frame_size;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const area = compute_polygon_area_2d(cutout_points, cutout_vertex_count);
|
|
114
|
+
|
|
115
|
+
console.log(`Cutout area: ${area}`);
|
|
116
|
+
|
|
117
|
+
if (area >= 0.99 && cutout_vertex_count >= 4) {
|
|
118
|
+
// default back to aligned quad, produced result is a degradation
|
|
119
|
+
return new Float32Array([
|
|
120
|
+
0, 0,
|
|
121
|
+
1, 0,
|
|
122
|
+
1, 1,
|
|
123
|
+
0, 1
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return cutout_points;
|
|
128
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Matrix4, Shape, ShapeBufferGeometry } from "three";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]} cutout
|
|
6
|
+
* @return {THREE.BufferGeometry}
|
|
7
|
+
*/
|
|
8
|
+
export function build_geometry_from_cutout_shape(cutout) {
|
|
9
|
+
|
|
10
|
+
const shape = new Shape();
|
|
11
|
+
|
|
12
|
+
shape.moveTo(cutout[0], cutout[1]);
|
|
13
|
+
|
|
14
|
+
for (let i = 2; i < cutout.length; i += 2) {
|
|
15
|
+
shape.lineTo(cutout[i], cutout[i + 1]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
shape.closePath();
|
|
19
|
+
|
|
20
|
+
const geometry = new ShapeBufferGeometry(shape);
|
|
21
|
+
|
|
22
|
+
// move shape by 0.5 to center on origin
|
|
23
|
+
const attribute = geometry.getAttribute('position');
|
|
24
|
+
|
|
25
|
+
const mat = new Matrix4();
|
|
26
|
+
mat.makeTranslation(-0.5, -0.5, 0);
|
|
27
|
+
|
|
28
|
+
attribute.applyMatrix4(mat);
|
|
29
|
+
//
|
|
30
|
+
|
|
31
|
+
return geometry;
|
|
32
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
2
|
+
import { three_object_to_entity_composition } from "../../../ecs/mesh-v2/three_object_to_entity_composition.js";
|
|
3
|
+
import { ShadedGeometry } from "../../../ecs/mesh-v2/ShadedGeometry.js";
|
|
4
|
+
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {Engine} engine
|
|
9
|
+
* @param {string} url
|
|
10
|
+
* @return {Promise<{mesh:ShadedGeometry,transform:mat4}[]>}
|
|
11
|
+
*/
|
|
12
|
+
export async function load_mesh_for_bake(engine, url) {
|
|
13
|
+
|
|
14
|
+
const gltf_asset = await engine.assetManager.promise(url, GameAssetType.ModelGLTF_JSON);
|
|
15
|
+
|
|
16
|
+
const node_hierarchy = three_object_to_entity_composition(gltf_asset.create());
|
|
17
|
+
|
|
18
|
+
const objects = [];
|
|
19
|
+
|
|
20
|
+
node_hierarchy.traverse(n => {
|
|
21
|
+
const sg = n.entity.getComponent(ShadedGeometry);
|
|
22
|
+
if (sg !== null) {
|
|
23
|
+
objects.push({
|
|
24
|
+
mesh: sg,
|
|
25
|
+
transform: n.entity.getComponent(Transform).matrix
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return objects;
|
|
31
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { buildCanvasViewFromTexture } from "../../../render/visibility/hiz/buildCanvasViewFromTexture.js";
|
|
2
|
+
import EmptyView from "../../../../../view/elements/EmptyView.js";
|
|
3
|
+
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {ImpostorDescription} impostor
|
|
7
|
+
* @returns {View}
|
|
8
|
+
*/
|
|
9
|
+
function makeGrid(impostor) {
|
|
10
|
+
const vGrid = new CanvasView();
|
|
11
|
+
|
|
12
|
+
vGrid.size.set(impostor.resolution, impostor.resolution);
|
|
13
|
+
|
|
14
|
+
const ctx = vGrid.context2d;
|
|
15
|
+
|
|
16
|
+
ctx.strokeStyle = "rgba(64,255,0,0.5)";
|
|
17
|
+
ctx.lineWidth = 1;
|
|
18
|
+
|
|
19
|
+
ctx.beginPath();
|
|
20
|
+
|
|
21
|
+
const frame_size = impostor.resolution / impostor.frame_count;
|
|
22
|
+
|
|
23
|
+
for (let i = 0; i < impostor.frame_count; i++) {
|
|
24
|
+
|
|
25
|
+
ctx.moveTo(0, i * frame_size);
|
|
26
|
+
ctx.lineTo(impostor.resolution, i * frame_size);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < impostor.frame_count; i++) {
|
|
30
|
+
ctx.moveTo(i * frame_size, 0);
|
|
31
|
+
ctx.lineTo(i * frame_size, impostor.resolution);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ctx.stroke();
|
|
35
|
+
|
|
36
|
+
vGrid.css({
|
|
37
|
+
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
top: '0',
|
|
40
|
+
left: '0'
|
|
41
|
+
});
|
|
42
|
+
return vGrid;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param {ImpostorDescription} impostor
|
|
48
|
+
* @param {THREE.WebGLRenderer} renderer
|
|
49
|
+
* @param {'albedo'|'normal'|'depth'|'alpha'} [mode]
|
|
50
|
+
* @param {boolean} [show_grid]
|
|
51
|
+
* @return {View}
|
|
52
|
+
*/
|
|
53
|
+
export function makeImpostorAtlasPreview({
|
|
54
|
+
impostor,
|
|
55
|
+
renderer,
|
|
56
|
+
mode = 'albedo',
|
|
57
|
+
show_grid = true
|
|
58
|
+
}) {
|
|
59
|
+
|
|
60
|
+
const options = {};
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
switch (mode) {
|
|
64
|
+
case "normal":
|
|
65
|
+
options.swizzle = ['r', 'g', 'b', 1];
|
|
66
|
+
options.texture = impostor.rt.texture[1]
|
|
67
|
+
break
|
|
68
|
+
case "alpha":
|
|
69
|
+
options.swizzle = ['a', 'a', 'a', 1];
|
|
70
|
+
options.texture = impostor.rt.texture[0]
|
|
71
|
+
break;
|
|
72
|
+
case "depth":
|
|
73
|
+
options.swizzle = ['a', 'a', 'a', 1];
|
|
74
|
+
options.texture = impostor.rt.texture[1]
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
console.warn(`Unsupported mode '${mode}', defaulting to albedo`);
|
|
78
|
+
//fall-through
|
|
79
|
+
case 'albedo':
|
|
80
|
+
options.swizzle = ['r', 'g', 'b', 1];
|
|
81
|
+
options.texture = impostor.rt.texture[0]
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const ctrl = buildCanvasViewFromTexture(Object.assign({ renderer }, options));
|
|
86
|
+
|
|
87
|
+
ctrl.view.css({
|
|
88
|
+
opacity: 1,
|
|
89
|
+
position: 'absolute',
|
|
90
|
+
top: '0',
|
|
91
|
+
left: '0'
|
|
92
|
+
});
|
|
93
|
+
ctrl.render();
|
|
94
|
+
|
|
95
|
+
const vContainer = new EmptyView();
|
|
96
|
+
|
|
97
|
+
vContainer.addChild(ctrl.view);
|
|
98
|
+
|
|
99
|
+
if (show_grid) {
|
|
100
|
+
|
|
101
|
+
const vGrid = makeGrid(impostor);
|
|
102
|
+
|
|
103
|
+
vContainer.addChild(vGrid);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return vContainer;
|
|
107
|
+
}
|
|
@@ -2,7 +2,7 @@ import { traverseThreeObject } from "../../ecs/highlight/renderer/traverseThreeO
|
|
|
2
2
|
import { TextureAttachmentsByMaterialType } from "../../../asset/loaders/material/TextureAttachmensByMaterialType.js";
|
|
3
3
|
import { HashMap } from "../../../../core/collection/HashMap.js";
|
|
4
4
|
import AABB2 from "../../../../core/geom/AABB2.js";
|
|
5
|
-
import { MaxRectanglesPacker } from "../../../../core/geom/packing/MaxRectangles.js";
|
|
5
|
+
import { MaxRectanglesPacker } from "../../../../core/geom/packing/max-rect/MaxRectangles.js";
|
|
6
6
|
import { Sampler2D } from "../../texture/sampler/Sampler2D.js";
|
|
7
7
|
import { array_push_if_unique } from "../../../../core/collection/array/array_push_if_unique.js";
|
|
8
8
|
import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
|
|
@@ -21,10 +21,14 @@ import { convertTexture2Sampler2D } from "../../texture/sampler/convertTexture2S
|
|
|
21
21
|
import { BUFFER_GEOMETRY_UVS } from "./BUFFER_GEOMETRY_UVS.js";
|
|
22
22
|
import { is_compliant_mesh } from "./is_compliant_mesh.js";
|
|
23
23
|
import { MaterialDescriptor } from "./MaterialDescriptor.js";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
computeThreeTextureTypeFromDataType
|
|
26
|
+
} from "../../render/forward_plus/data/computeThreeTextureTypeFromDataType.js";
|
|
25
27
|
import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
|
|
26
28
|
import { DataType } from "../../../../core/collection/table/DataType.js";
|
|
27
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
compute_typed_array_constructor_from_data_type
|
|
31
|
+
} from "../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
28
32
|
import { copy_Sampler2D_channel_data } from "../../texture/sampler/copy_Sampler2D_channel_data.js";
|
|
29
33
|
import { channelCountToThreeTextureFormat } from "../../texture/channelCountToThreeTextureFormat.js";
|
|
30
34
|
import { prepare_atlas_texture } from "./prepare_atlas_texture.js";
|
package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
OneMinusSrcAlphaFactor,
|
|
8
8
|
ShaderMaterial,
|
|
9
9
|
UniformsLib,
|
|
10
|
-
UniformsUtils
|
|
10
|
+
UniformsUtils,
|
|
11
|
+
Vector2 as ThreeVector2
|
|
11
12
|
} from "three";
|
|
12
|
-
import { Vector2 as ThreeVector2 } from "three/src/math/Vector2.js";
|
|
13
13
|
|
|
14
14
|
const CHUNK_LAMBERT_LIGHTING = `
|
|
15
15
|
vec3 diffuse = vec3( 1.0 );
|
|
@@ -17,13 +17,6 @@ export class ForwardPlusRenderingPlugin extends EnginePlugin {
|
|
|
17
17
|
light_manager: this.__light_manager,
|
|
18
18
|
resolution: this.__resolution
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Track lifecycle state
|
|
23
|
-
* @type {boolean}
|
|
24
|
-
* @private
|
|
25
|
-
*/
|
|
26
|
-
this.__state_is_running = false;
|
|
27
20
|
}
|
|
28
21
|
|
|
29
22
|
/**
|
|
@@ -44,12 +37,6 @@ export class ForwardPlusRenderingPlugin extends EnginePlugin {
|
|
|
44
37
|
}
|
|
45
38
|
|
|
46
39
|
async startup() {
|
|
47
|
-
if (this.__state_is_running) {
|
|
48
|
-
throw new Error("Already running");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.__state_is_running = true;
|
|
52
|
-
|
|
53
40
|
const lm = this.__light_manager;
|
|
54
41
|
|
|
55
42
|
lm.setTileMapResolution(16, 8, 8);
|
|
@@ -70,12 +57,6 @@ export class ForwardPlusRenderingPlugin extends EnginePlugin {
|
|
|
70
57
|
}
|
|
71
58
|
|
|
72
59
|
async shutdown() {
|
|
73
|
-
if (!this.__state_is_running) {
|
|
74
|
-
throw new Error("Not running");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
this.__state_is_running = false;
|
|
78
|
-
|
|
79
60
|
const graphics = this.engine.graphics;
|
|
80
61
|
|
|
81
62
|
const is_material_removed = graphics.getMaterialManager().removeCompileStep(this.__material_transformer);
|
|
@@ -1561,10 +1561,10 @@ function draw_camera_view_planes() {
|
|
|
1561
1561
|
// prepare_scene_2();
|
|
1562
1562
|
// prepare_scene_decal_0();
|
|
1563
1563
|
// prepare_scene_decal_1();
|
|
1564
|
-
prepare_scene_decal_2();
|
|
1564
|
+
// prepare_scene_decal_2();
|
|
1565
1565
|
// prepare_scene_9();
|
|
1566
1566
|
// prepare_scene_2();
|
|
1567
|
-
|
|
1567
|
+
prepare_scene_0();
|
|
1568
1568
|
animate();
|
|
1569
1569
|
|
|
1570
1570
|
// draw_camera_view_planes();
|
|
@@ -14,6 +14,7 @@ import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../../../geometry/FULL_SCREEN_TRI
|
|
|
14
14
|
import { formatToChannelCount } from "../../../texture/formatToChannelCount.js";
|
|
15
15
|
import { glsl_gen_swizzled_read } from "../../../shaders/glsl_gen_swizzled_read.js";
|
|
16
16
|
import { assert } from "../../../../../core/assert.js";
|
|
17
|
+
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -92,6 +93,7 @@ function makeShader({ texture, alpha_override, swizzle }) {
|
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
|
|
95
97
|
/**
|
|
96
98
|
*
|
|
97
99
|
* @param {number} height
|
|
@@ -100,29 +102,21 @@ function makeShader({ texture, alpha_override, swizzle }) {
|
|
|
100
102
|
* @param {THREE.WebGLRenderer} renderer
|
|
101
103
|
* @param {boolean} [flipY]
|
|
102
104
|
* @param {(string|number)[]} [swizzle]
|
|
103
|
-
* @
|
|
105
|
+
* @param {Sampler2D} [destination]
|
|
106
|
+
* @return {{destination: Sampler2D, render: function}}
|
|
104
107
|
*/
|
|
105
|
-
export function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
export function renderSamplerFromTexture({
|
|
109
|
+
|
|
110
|
+
texture = CheckersTexture.create(),
|
|
111
|
+
width = texture.image.width,
|
|
112
|
+
height = texture.image.height,
|
|
113
|
+
renderer,
|
|
114
|
+
flipY = true,
|
|
115
|
+
swizzle = ['r', 'g', 'b', 'a'],
|
|
116
|
+
destination = Sampler2D.uint8clamped(4, width, height)
|
|
117
|
+
}) {
|
|
114
118
|
assert.isArray(swizzle, 'swizzle');
|
|
115
119
|
|
|
116
|
-
const canvasView = new CanvasView();
|
|
117
|
-
canvasView.css({
|
|
118
|
-
position: 'absolute',
|
|
119
|
-
left: 0,
|
|
120
|
-
top: 0
|
|
121
|
-
});
|
|
122
|
-
canvasView.size.set(width, height);
|
|
123
|
-
|
|
124
|
-
const ctx = canvasView.context2d;
|
|
125
|
-
|
|
126
120
|
let copyShader = null;
|
|
127
121
|
|
|
128
122
|
const camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
@@ -147,8 +141,6 @@ export function buildCanvasViewFromTexture({
|
|
|
147
141
|
};
|
|
148
142
|
const renderTarget = new WebGLRenderTarget(width, height, renderTargetOptions);
|
|
149
143
|
|
|
150
|
-
const imageData = ctx.createImageData(width, height);
|
|
151
|
-
|
|
152
144
|
let __texture_cached = texture;
|
|
153
145
|
|
|
154
146
|
/**
|
|
@@ -172,7 +164,10 @@ export function buildCanvasViewFromTexture({
|
|
|
172
164
|
|
|
173
165
|
const render = () => {
|
|
174
166
|
|
|
175
|
-
getShader()
|
|
167
|
+
const shader = getShader();
|
|
168
|
+
|
|
169
|
+
shader.uniforms.tDiffuse.value = texture;
|
|
170
|
+
shader.uniformsNeedUpdate = true;
|
|
176
171
|
|
|
177
172
|
const _rt = renderer.getRenderTarget();
|
|
178
173
|
|
|
@@ -180,16 +175,15 @@ export function buildCanvasViewFromTexture({
|
|
|
180
175
|
|
|
181
176
|
renderer.render(scene, camera);
|
|
182
177
|
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
destination.resize(width, height);
|
|
185
179
|
|
|
186
|
-
|
|
180
|
+
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, destination.data);
|
|
187
181
|
|
|
188
182
|
renderer.setRenderTarget(_rt);
|
|
189
183
|
};
|
|
190
184
|
|
|
191
185
|
return {
|
|
192
|
-
|
|
186
|
+
destination,
|
|
193
187
|
render,
|
|
194
188
|
set texture(v) {
|
|
195
189
|
|
|
@@ -199,3 +193,65 @@ export function buildCanvasViewFromTexture({
|
|
|
199
193
|
}
|
|
200
194
|
}
|
|
201
195
|
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
*
|
|
199
|
+
* @param {number} height
|
|
200
|
+
* @param {number} width
|
|
201
|
+
* @param {THREE.Texture} texture
|
|
202
|
+
* @param {THREE.WebGLRenderer} renderer
|
|
203
|
+
* @param {boolean} [flipY]
|
|
204
|
+
* @param {(string|number)[]} [swizzle]
|
|
205
|
+
* @return {{view: View, render: function}}
|
|
206
|
+
*/
|
|
207
|
+
export function buildCanvasViewFromTexture({
|
|
208
|
+
texture,
|
|
209
|
+
width = texture.image.width,
|
|
210
|
+
height = texture.image.height,
|
|
211
|
+
renderer,
|
|
212
|
+
flipY = true,
|
|
213
|
+
swizzle
|
|
214
|
+
}) {
|
|
215
|
+
|
|
216
|
+
const canvasView = new CanvasView();
|
|
217
|
+
canvasView.css({
|
|
218
|
+
position: 'absolute',
|
|
219
|
+
left: 0,
|
|
220
|
+
top: 0
|
|
221
|
+
});
|
|
222
|
+
canvasView.size.set(width, height);
|
|
223
|
+
|
|
224
|
+
const ctx = canvasView.context2d;
|
|
225
|
+
|
|
226
|
+
const imageData = ctx.createImageData(width, height);
|
|
227
|
+
|
|
228
|
+
// wrap imageData in Sampler2D
|
|
229
|
+
const sampler = new Sampler2D(imageData.data, 4, width, height);
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
const ctrl = renderSamplerFromTexture({
|
|
233
|
+
texture,
|
|
234
|
+
width,
|
|
235
|
+
height,
|
|
236
|
+
flipY,
|
|
237
|
+
renderer,
|
|
238
|
+
swizzle,
|
|
239
|
+
destination: sampler
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
function render() {
|
|
244
|
+
ctrl.render();
|
|
245
|
+
|
|
246
|
+
ctx.putImageData(imageData, 0, 0);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
view: canvasView,
|
|
252
|
+
render,
|
|
253
|
+
set texture(v) {
|
|
254
|
+
ctrl.texture = v;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
Color,
|
|
3
|
+
LinearFilter,
|
|
4
|
+
NearestFilter,
|
|
5
|
+
RGBAFormat,
|
|
6
|
+
Scene,
|
|
7
|
+
ShaderMaterial,
|
|
8
|
+
Vector2,
|
|
9
|
+
VSMShadowMap,
|
|
10
|
+
WebGLRenderTarget
|
|
11
|
+
} from "three";
|
|
4
12
|
import Signal from "../../../core/events/signal/Signal.js";
|
|
5
|
-
import { ShaderMaterial } from "three/src/materials/ShaderMaterial.js";
|
|
6
13
|
import { fragment as vsm_frag, vertex as vsm_vert } from "./vsm.glsl.js";
|
|
7
14
|
import { renderScreenSpace } from "../render/utils/renderScreenSpace.js";
|
|
8
15
|
|