@woosh/meep-engine 2.41.0 → 2.42.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.
Files changed (98) hide show
  1. package/core/assert.js +2 -2
  2. package/core/collection/array/array_swap.js +3 -3
  3. package/core/collection/map/AsyncLoadingCache.js +47 -0
  4. package/core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.js +1 -1
  5. package/core/geom/3d/apply_mat4_transform_to_v3_array.js +2 -4
  6. package/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.js +28 -0
  7. package/core/geom/Quaternion.js +14 -0
  8. package/core/math/statistics/computeSampleSize_Cochran.js +3 -3
  9. package/editor/ecs/component/editors/geom/QuaternionEditor.js +12 -5
  10. package/engine/Engine.js +6 -1
  11. package/engine/EngineBootstrapper.js +2 -1
  12. package/engine/EngineHarness.js +13 -3
  13. package/engine/asset/AssetManager.js +97 -7
  14. package/engine/development/performance/AbstractMetric.js +1 -0
  15. package/engine/development/performance/RingBufferMetric.js +25 -4
  16. package/engine/ecs/EntityBuilder.js +29 -4
  17. package/engine/ecs/transform/Transform.js +23 -3
  18. package/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +17 -1
  19. package/engine/graphics/ecs/decal/v2/Decal.d.ts +11 -0
  20. package/engine/graphics/ecs/decal/v2/Decal.js +50 -0
  21. package/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts +8 -0
  22. package/engine/graphics/ecs/decal/v2/FPDecalSystem.js +201 -0
  23. package/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +278 -0
  24. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +8 -1
  25. package/engine/graphics/ecs/mesh-v2/allocate_v3.js +37 -0
  26. package/engine/graphics/ecs/mesh-v2/build_three_object.js +4 -0
  27. package/engine/graphics/geometry/MikkT/AddTriToGroup.js +10 -0
  28. package/engine/graphics/geometry/MikkT/AssignRecur.js +84 -0
  29. package/engine/graphics/geometry/MikkT/AvgTSpace.js +38 -0
  30. package/engine/graphics/geometry/MikkT/Build4RuleGroups.js +96 -0
  31. package/engine/graphics/geometry/MikkT/BuildNeighborsFast.js +137 -0
  32. package/engine/graphics/geometry/MikkT/CalcTexArea.js +31 -0
  33. package/engine/graphics/geometry/MikkT/CompareSubGroups.js +26 -0
  34. package/engine/graphics/geometry/MikkT/DegenEpilogue.js +220 -0
  35. package/engine/graphics/geometry/MikkT/DegenPrologue.js +115 -0
  36. package/engine/graphics/geometry/MikkT/EvalTspace.js +128 -0
  37. package/engine/graphics/geometry/MikkT/GenerateInitialVerticesIndexList.js +48 -0
  38. package/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.js +184 -0
  39. package/engine/graphics/geometry/MikkT/GenerateTSpaces.js +226 -0
  40. package/engine/graphics/geometry/MikkT/GetEdge.js +45 -0
  41. package/engine/graphics/geometry/MikkT/GetNormal.js +16 -0
  42. package/engine/graphics/geometry/MikkT/GetPosition.js +25 -0
  43. package/engine/graphics/geometry/MikkT/GetTexCoord.js +18 -0
  44. package/engine/graphics/geometry/MikkT/InitTriInfo.js +180 -0
  45. package/engine/graphics/geometry/MikkT/Length.js +10 -0
  46. package/engine/graphics/geometry/MikkT/MakeIndex.js +18 -0
  47. package/engine/graphics/geometry/MikkT/MikkTSpace.js +197 -2068
  48. package/engine/graphics/geometry/MikkT/NormalizeSafe.js +21 -0
  49. package/engine/graphics/geometry/MikkT/NotZero.js +10 -0
  50. package/engine/graphics/geometry/MikkT/QuickSort.js +54 -0
  51. package/engine/graphics/geometry/MikkT/QuickSortEdges.js +71 -0
  52. package/engine/graphics/geometry/MikkT/SSubGroup.js +15 -0
  53. package/engine/graphics/geometry/MikkT/STSpace.js +36 -0
  54. package/engine/graphics/geometry/MikkT/constants/GROUP_WITH_ANY.js +1 -0
  55. package/engine/graphics/geometry/MikkT/constants/INTERNAL_RND_SORT_SEED.js +1 -0
  56. package/engine/graphics/geometry/MikkT/constants/MARK_DEGENERATE.js +1 -0
  57. package/engine/graphics/geometry/MikkT/constants/ORIENT_PRESERVING.js +1 -0
  58. package/engine/graphics/geometry/MikkT/constants/QUAD_ONE_DEGEN_TRI.js +1 -0
  59. package/engine/graphics/geometry/MikkT/m_getNormal.js +16 -0
  60. package/engine/graphics/geometry/MikkT/m_getNumFaces.js +8 -0
  61. package/engine/graphics/geometry/MikkT/m_getNumVerticesOfFace.js +11 -0
  62. package/engine/graphics/geometry/MikkT/m_getPosition.js +20 -0
  63. package/engine/graphics/geometry/MikkT/m_getTexCoord.js +16 -0
  64. package/engine/graphics/geometry/MikkT/m_setTSpace.js +35 -0
  65. package/engine/graphics/geometry/MikkT/m_setTSpaceBasic.js +22 -0
  66. package/engine/graphics/geometry/MikkT/malloc.js +16 -0
  67. package/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.js +52 -0
  68. package/engine/graphics/geometry/buffered/computeGeometryEquality.js +1 -1
  69. package/engine/graphics/geometry/buffered/computeGeometryHash.js +1 -1
  70. package/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -14
  71. package/engine/graphics/impostors/octahedral/ImpostorDescription.js +6 -0
  72. package/engine/graphics/impostors/octahedral/README.md +1 -0
  73. package/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere.js +25 -22
  74. package/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere_radius_only.js +37 -0
  75. package/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +30 -1
  76. package/engine/graphics/impostors/octahedral/grid/HemiOctahedralUvEncoder.js +1 -1
  77. package/engine/graphics/impostors/octahedral/prototypeBaker.js +121 -22
  78. package/engine/graphics/impostors/octahedral/shader/BakeShaderStandard.js +46 -7
  79. package/engine/graphics/impostors/octahedral/shader/ImpostorShaderV0.js +349 -0
  80. package/engine/graphics/impostors/octahedral/shader/ImpostorShaderV1.js +74 -0
  81. package/engine/graphics/impostors/octahedral/shader/glsl/v1/common.glsl +209 -0
  82. package/engine/graphics/impostors/octahedral/shader/glsl/v1/flagment.glsl +80 -0
  83. package/engine/graphics/impostors/octahedral/shader/glsl/v1/vertex.glsl +350 -0
  84. package/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +1 -1
  85. package/engine/graphics/render/forward_plus/LightManager.js +17 -7
  86. package/engine/graphics/render/forward_plus/data/TextureBackedMemoryRegion.js +7 -1
  87. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +13 -5
  88. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +3 -1
  89. package/engine/graphics/render/forward_plus/model/Decal.js +19 -2
  90. package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +14 -2
  91. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +2 -2
  92. package/engine/graphics/texture/sampler/Sampler2D.js +10 -10
  93. package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +117 -11
  94. package/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +66 -0
  95. package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +2 -2
  96. package/engine/intelligence/behavior/util/RotationBehavior.js +69 -0
  97. package/generation/example/filters/SampleGroundMoistureFilter.js +5 -5
  98. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import {System} from "../../../../ecs/System";
2
+ import {Decal} from "./Decal";
3
+ import {Transform} from "../../../../ecs/transform/Transform";
4
+ import Engine from "../../../../Engine";
5
+
6
+ export class FPDecalSystem extends System<Decal, Transform> {
7
+ constructor(engine: Engine)
8
+ }
@@ -0,0 +1,201 @@
1
+ import { AbstractContextSystem } from "../../../../ecs/system/AbstractContextSystem.js";
2
+ import { SystemEntityContext } from "../../../../ecs/system/SystemEntityContext.js";
3
+ import { Decal } from "./Decal.js";
4
+ import { Transform } from "../../../../ecs/transform/Transform.js";
5
+ import { ForwardPlusRenderingPlugin } from "../../../render/forward_plus/plugin/ForwardPlusRenderingPlugin.js";
6
+ import { Reference } from "../../../../reference/v2/Reference.js";
7
+ import { Decal as FPDecal } from '../../../render/forward_plus/model/Decal.js';
8
+ import { AssetManager } from "../../../../asset/AssetManager.js";
9
+ import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
10
+ import { GameAssetType } from "../../../../asset/GameAssetType.js";
11
+ import { assert } from "../../../../../core/assert.js";
12
+ import { AsyncLoadingCache } from "../../../../../core/collection/map/AsyncLoadingCache.js";
13
+
14
+ const placeholder_texture = Sampler2D.uint8(4, 1, 1);
15
+ placeholder_texture.data.fill(255);
16
+
17
+ class Context extends SystemEntityContext {
18
+ constructor() {
19
+ super();
20
+
21
+ /**
22
+ *
23
+ * @type {FPDecal|null}
24
+ * @private
25
+ */
26
+ this.__fp_decal = null;
27
+ }
28
+
29
+ /**
30
+ * @return {ForwardPlusRenderingPlugin}
31
+ * @private
32
+ */
33
+ getPlugin() {
34
+ return this.system.__fp_plugin.getValue();
35
+ }
36
+
37
+ /**
38
+ *
39
+ * @returns {Transform}
40
+ */
41
+ getTransform() {
42
+ return this.components[1];
43
+ }
44
+
45
+ __update_transform() {
46
+ /**
47
+ *
48
+ * @type {Transform}
49
+ */
50
+ const transform = this.getTransform();
51
+
52
+ this.__fp_decal.setTransform(transform.matrix);
53
+ }
54
+
55
+ async __load_texture() {
56
+
57
+ /**
58
+ *
59
+ * @type {Decal}
60
+ */
61
+ const decal_spec = this.components[0];
62
+
63
+ const _uri = decal_spec.uri;
64
+
65
+ if (decal_spec.__cached_sampler !== null && decal_spec.__cached_uri === _uri) {
66
+ // cached asset is still relevant
67
+ return;
68
+ }
69
+
70
+ /**
71
+ *
72
+ * @type {FPDecalSystem}
73
+ */
74
+ const system = this.system;
75
+
76
+ /**
77
+ * @type {Sampler2D}
78
+ */
79
+ const loaded_texture = await system.__texture_cache.get(_uri);
80
+
81
+ assert.defined(loaded_texture, 'loaded_texture');
82
+ assert.notNull(loaded_texture, 'loaded_texture');
83
+ assert.equal(loaded_texture.isSampler2D, true, 'texture.isSampler2D !== true');
84
+
85
+ decal_spec.__cached_sampler = loaded_texture;
86
+ decal_spec.__cached_uri = _uri;
87
+ }
88
+
89
+ link() {
90
+ const plugin = this.getPlugin();
91
+
92
+ const lm = plugin.getLightManager();
93
+
94
+ const fpDecal = new FPDecal();
95
+
96
+ this.__fp_decal = fpDecal;
97
+
98
+
99
+ this.__update_transform();
100
+
101
+ const transform = this.getTransform();
102
+ transform.subscribeAllChanges(this.__update_transform, this);
103
+
104
+ /**
105
+ *
106
+ * @type {Decal}
107
+ */
108
+ const decal_spec = this.components[0];
109
+
110
+ this.__load_texture().then(() => {
111
+
112
+ if (!this.__is_linked) {
113
+ // not linked anymore
114
+ return;
115
+ }
116
+
117
+ const sampler = decal_spec.__cached_sampler;
118
+
119
+ if (sampler === null) {
120
+ return;
121
+ }
122
+
123
+ fpDecal.texture_diffuse = sampler;
124
+
125
+ if (this.__fp_decal === fpDecal) {
126
+ lm.addLight(fpDecal);
127
+ }
128
+ });
129
+
130
+
131
+ super.link();
132
+ }
133
+
134
+ unlink() {
135
+
136
+ this.getPlugin()
137
+ .getLightManager()
138
+ .removeLight(this.__fp_decal);
139
+
140
+ this.__fp_decal = null;
141
+
142
+ const transform = this.getTransform();
143
+ transform.subscribeAllChanges(this.__update_transform, this);
144
+
145
+ super.unlink();
146
+ }
147
+ }
148
+
149
+ export class FPDecalSystem extends AbstractContextSystem {
150
+ /**
151
+ *
152
+ * @param {Engine} engine
153
+ */
154
+ constructor(engine) {
155
+ super(Context);
156
+
157
+ this.dependencies = [Decal, Transform];
158
+
159
+ /**
160
+ *
161
+ * @type {Map<string, Sampler2D>}
162
+ * @private
163
+ */
164
+ this.__texture_cache = new AsyncLoadingCache(new Map(), (key) => {
165
+ return this.__assets.promise(key, GameAssetType.Image).then(asset => asset.create());
166
+ });
167
+
168
+ /**
169
+ *
170
+ * @type {AssetManager}
171
+ * @private
172
+ */
173
+ this.__assets = engine.assetManager;
174
+
175
+ /**
176
+ *
177
+ * @type {Engine}
178
+ * @private
179
+ */
180
+ this.__engine = engine;
181
+
182
+ /**
183
+ *
184
+ * @type {Reference<ForwardPlusRenderingPlugin>|null}
185
+ * @private
186
+ */
187
+ this.__fp_plugin = Reference.NULL;
188
+ }
189
+
190
+ async startup(em, ready_callback, error_callback) {
191
+ this.__fp_plugin = await this.__engine.plugins.acquire(ForwardPlusRenderingPlugin);
192
+
193
+ super.startup(em, ready_callback, error_callback);
194
+ }
195
+
196
+ shutdown(em, ready_callback, error_callback) {
197
+ this.__fp_plugin.release();
198
+
199
+ super.shutdown(em, ready_callback, error_callback);
200
+ }
201
+ }
@@ -0,0 +1,278 @@
1
+ import { EngineHarness } from "../../../../EngineHarness.js";
2
+ import { FPDecalSystem } from "./FPDecalSystem.js";
3
+ import EntityBuilder, { EntityBuilderFlags } from "../../../../ecs/EntityBuilder.js";
4
+ import { Decal } from "./Decal.js";
5
+ import { Transform } from "../../../../ecs/transform/Transform.js";
6
+ import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
7
+ import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
8
+ import { randomFromArray } from "../../../../../core/math/random/randomFromArray.js";
9
+ import { BehaviorSystem } from "../../../../intelligence/behavior/ecs/BehaviorSystem.js";
10
+ import { SGMeshSystem } from "../../mesh-v2/aggregate/SGMeshSystem.js";
11
+ import { ShadedGeometrySystem } from "../../mesh-v2/ShadedGeometrySystem.js";
12
+ import { TransformAttachmentSystem } from "../../../../ecs/transform-attachment/TransformAttachmentSystem.js";
13
+ import { SGMesh } from "../../mesh-v2/aggregate/SGMesh.js";
14
+ import { GameAssetType } from "../../../../asset/GameAssetType.js";
15
+ import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
16
+
17
+ const decal_urls = `data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_13_t.png
18
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_01_t.png
19
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_02_t.png
20
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_03_t.png
21
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_04_t.png
22
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_05_t.png
23
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_06_t.png
24
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_07_t.png
25
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_08_t.png
26
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_09_t.png
27
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_10_t.png
28
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_11_t.png
29
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_12_t.png
30
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_13_t.png
31
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_14_t.png
32
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_01_t.png
33
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_02_t.png
34
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_03_t.png
35
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_04_t.png
36
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_05_t.png
37
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_06_t.png
38
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_07_t.png
39
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_08_t.png
40
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_09_t.png
41
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_10_b.png
42
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_11_t.png
43
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_12_t.png
44
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_01_t.png
45
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_02_t.png
46
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_03_t.png
47
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_04_t.png
48
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_05_t.png
49
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_06_t.png
50
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_07_t.png
51
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_08_t.png
52
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_09_t.png
53
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_10_t.png
54
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_11_t.png
55
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_12_t.png
56
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_13_t.png
57
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_14_t.png
58
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_15_t.png
59
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_16_t.png
60
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_17_t.png
61
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_01_t.png
62
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_02_t.png
63
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_03_t.png
64
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_04_t.png
65
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_05_t.png
66
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_06_t.png
67
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_07_t.png
68
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_08_t.png
69
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_09_t.png
70
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_10_t.png
71
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_11_t.png
72
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_12_t.png
73
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_01_t.png
74
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_02_t.png
75
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_03_t.png
76
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_04_t.png
77
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_05_t.png
78
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_06_t.png
79
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_07_t.png
80
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_08_t.png
81
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_09_t.png
82
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_10_t.png
83
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_11_t.png
84
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_12_t.png
85
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_01_t.png
86
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_02_t.png
87
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_03_t.png
88
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_04_t.png
89
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_05_t.png
90
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_06_t.png
91
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_07_t.png
92
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_08_t.png
93
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_09_t.png
94
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_10_t.png
95
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_11_t.png
96
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_12_t.png
97
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_01_t.png
98
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_02_t.png
99
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_03_t.png
100
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_04_t.png
101
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_05_t.png
102
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_06_t.png
103
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_07_t.png
104
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_08_t.png
105
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_09_t.png
106
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_10_t.png
107
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_11_t.png
108
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_12_t.png
109
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_13_t.png
110
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_01_t.png
111
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_02_t.png
112
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_03_t.png
113
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_04_t.png
114
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_05_t.png
115
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_06_t.png
116
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_07_t.png
117
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_08_t.png
118
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_09_t.png
119
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_10_t.png
120
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_11_t.png
121
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_12_t.png
122
+ data/textures/icons/sci-fi-nathan/v6/Proc normal_3.png
123
+ data/textures/icons/sci-fi-nathan/v6/Proc strong_1.png
124
+ data/textures/icons/sci-fi-nathan/v6/Proc strong_2.png
125
+ data/textures/icons/sci-fi-nathan/v6/Proc strong_3.png
126
+ data/textures/icons/sci-fi-nathan/v6/Proc very strong_1.png
127
+ data/textures/icons/sci-fi-nathan/v6/Proc very strong_2.png
128
+ data/textures/icons/sci-fi-nathan/v6/Proc very strong_3.png
129
+ data/textures/icons/sci-fi-nathan/v6/Proc very weak_1.png
130
+ data/textures/icons/sci-fi-nathan/v6/Proc very weak_2.png
131
+ data/textures/icons/sci-fi-nathan/v6/Proc very weak_3.png
132
+ data/textures/icons/sci-fi-nathan/v6/Proc weak_1.png
133
+ data/textures/icons/sci-fi-nathan/v6/Proc weak_2.png
134
+ data/textures/icons/sci-fi-nathan/v6/Proc weak_3.png
135
+ data/textures/icons/sci-fi-nathan/v6/Core normal_1.png
136
+ data/textures/icons/sci-fi-nathan/v6/Core normal_2.png
137
+ data/textures/icons/sci-fi-nathan/v6/Core normal_3.png
138
+ data/textures/icons/sci-fi-nathan/v6/Core strong_1.png
139
+ data/textures/icons/sci-fi-nathan/v6/Core strong_2.png
140
+ data/textures/icons/sci-fi-nathan/v6/Core strong_3.png
141
+ data/textures/icons/sci-fi-nathan/v6/Core very strong_1.png
142
+ data/textures/icons/sci-fi-nathan/v6/Core very strong_2.png
143
+ data/textures/icons/sci-fi-nathan/v6/Core very strong_3.png
144
+ data/textures/icons/sci-fi-nathan/v6/Core very weak_1.png
145
+ data/textures/icons/sci-fi-nathan/v6/Core very weak_2.png
146
+ data/textures/icons/sci-fi-nathan/v6/Core very weak_3.png
147
+ data/textures/icons/sci-fi-nathan/v6/Core weak_1.png
148
+ data/textures/icons/sci-fi-nathan/v6/Core weak_2.png
149
+ data/textures/icons/sci-fi-nathan/v6/Core weak_3.png
150
+ data/textures/icons/sci-fi-nathan/v6/Memory normal_1.png
151
+ data/textures/icons/sci-fi-nathan/v6/Memory normal_2.png
152
+ data/textures/icons/sci-fi-nathan/v6/Memory normal_3.png
153
+ data/textures/icons/sci-fi-nathan/v6/Memory strong_1.png
154
+ data/textures/icons/sci-fi-nathan/v6/Memory strong_2.png
155
+ data/textures/icons/sci-fi-nathan/v6/Memory strong_3.png
156
+ data/textures/icons/sci-fi-nathan/v6/Memory very strong_1.png
157
+ data/textures/icons/sci-fi-nathan/v6/Memory very strong_2.png
158
+ data/textures/icons/sci-fi-nathan/v6/Memory very strong_3.png
159
+ data/textures/icons/sci-fi-nathan/v6/Memory very weak_1.png
160
+ data/textures/icons/sci-fi-nathan/v6/Memory very weak_2.png
161
+ data/textures/icons/sci-fi-nathan/v6/Memory very weak_3.png
162
+ data/textures/icons/sci-fi-nathan/v6/Memory weak_1.png
163
+ data/textures/icons/sci-fi-nathan/v6/Memory weak_2.png
164
+ data/textures/icons/sci-fi-nathan/v6/Memory weak_3.png
165
+ data/textures/icons/sci-fi-nathan/v6/Module normal_1.png
166
+ data/textures/icons/sci-fi-nathan/v6/Module normal_2.png
167
+ data/textures/icons/sci-fi-nathan/v6/Module normal_3.png
168
+ data/textures/icons/sci-fi-nathan/v6/Module strong_1.png
169
+ data/textures/icons/sci-fi-nathan/v6/Module strong_2.png
170
+ data/textures/icons/sci-fi-nathan/v6/Module strong_3.png
171
+ data/textures/icons/sci-fi-nathan/v6/Module very strong_1.png
172
+ data/textures/icons/sci-fi-nathan/v6/Module very strong_2.png
173
+ data/textures/icons/sci-fi-nathan/v6/Module very strong_3.png
174
+ data/textures/icons/sci-fi-nathan/v6/Module very weak_1.png
175
+ data/textures/icons/sci-fi-nathan/v6/Module very weak_2.png
176
+ data/textures/icons/sci-fi-nathan/v6/Module very weak_3.png
177
+ data/textures/icons/sci-fi-nathan/v6/Module weak_1.png
178
+ data/textures/icons/sci-fi-nathan/v6/Module weak_2.png
179
+ data/textures/icons/sci-fi-nathan/v6/Module weak_3.png
180
+ data/textures/icons/sci-fi-nathan/v6/Power normal_1.png
181
+ data/textures/icons/sci-fi-nathan/v6/Power normal_2.png
182
+ data/textures/icons/sci-fi-nathan/v6/Power normal_3.png
183
+ data/textures/icons/sci-fi-nathan/v6/Power strong_1.png
184
+ data/textures/icons/sci-fi-nathan/v6/Power strong_2.png
185
+ data/textures/icons/sci-fi-nathan/v6/Power strong_3.png
186
+ data/textures/icons/sci-fi-nathan/v6/Power very strong_1.png
187
+ data/textures/icons/sci-fi-nathan/v6/Power very strong_2.png
188
+ data/textures/icons/sci-fi-nathan/v6/Power very strong_3.png
189
+ data/textures/icons/sci-fi-nathan/v6/Power very weak_1.png
190
+ data/textures/icons/sci-fi-nathan/v6/Power very weak_2.png
191
+ data/textures/icons/sci-fi-nathan/v6/Power very weak_3.png
192
+ data/textures/icons/sci-fi-nathan/v6/Power weak_1.png
193
+ data/textures/icons/sci-fi-nathan/v6/Power weak_2.png
194
+ data/textures/icons/sci-fi-nathan/v6/Power weak_3.png
195
+ data/textures/icons/sci-fi-nathan/v6/Proc normal_1.png
196
+ data/textures/icons/sci-fi-nathan/v6/Proc normal_2.png
197
+ data/textures/utility/sampling-test.png`
198
+ .split('\n')
199
+ .map(a => a.trim());
200
+
201
+ function promise_time_out(t) {
202
+ return new Promise(resolve => {
203
+ setTimeout(resolve, t);
204
+ });
205
+ }
206
+
207
+ /**
208
+ *
209
+ * @param {Engine} engine
210
+ */
211
+ async function main(engine) {
212
+
213
+ await EngineHarness.buildBasics({
214
+ engine,
215
+ enableWater: false,
216
+ cameraFarDistance: 300
217
+ });
218
+
219
+ new EntityBuilder()
220
+ .add(SGMesh.fromURL("moicon/gnutti_not_optimized/model.gltf"))
221
+ .add(Transform.fromJSON({
222
+ position: { x: 10, y: 3, z: 10 },
223
+ scale: 1.5
224
+ }))
225
+ // .build(engine.entityManager.dataset);
226
+
227
+
228
+ const random = seededRandom();
229
+
230
+ const ENTITY_COUNT = 10000;
231
+
232
+ for (let i = 0; i < ENTITY_COUNT; i++) {
233
+ const decal = new Decal();
234
+
235
+ decal.uri = randomFromArray(random, decal_urls);
236
+
237
+ const entity = new EntityBuilder();
238
+
239
+ entity.clearFlag(EntityBuilderFlags.WatchDestruction);
240
+
241
+ const transform = new Transform();
242
+ transform.position.set(
243
+ randomFloatBetween(random, -400, 400),
244
+ randomFloatBetween(random, 0, 0),
245
+ randomFloatBetween(random, -400, 400)
246
+ );
247
+ transform.rotation.random(random);
248
+ transform.scale.setScalar(0.5);
249
+
250
+ entity
251
+ .add(transform)
252
+ .add(decal)
253
+ // .add(BehaviorComponent.fromOne(RotationBehavior.fromJSON({ speed: 1 })))
254
+
255
+ entity.build(engine.entityManager.dataset);
256
+
257
+ }
258
+
259
+ await promise_time_out(10);
260
+
261
+
262
+ }
263
+
264
+ new EngineHarness()
265
+ .initialize({
266
+ configuration(config, engine) {
267
+ const gltfAssetLoader = new GLTFAssetLoader();
268
+
269
+ config.addLoader(GameAssetType.ModelGLTF_JSON, gltfAssetLoader);
270
+ config.addLoader(GameAssetType.ModelGLTF, gltfAssetLoader);
271
+
272
+ config.addSystem(new FPDecalSystem(engine));
273
+ config.addSystem(new BehaviorSystem(engine))
274
+ config.addSystem(new SGMeshSystem(engine));
275
+ config.addSystem(new ShadedGeometrySystem(engine));
276
+ config.addSystem(new TransformAttachmentSystem(engine));
277
+ }
278
+ }).then(main);
@@ -1,4 +1,3 @@
1
- import { LeafNode } from "../../../../core/bvh2/LeafNode.js";
2
1
  import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
3
2
  import { DrawMode } from "./DrawMode.js";
4
3
  import { ShadedGeometryFlags } from "./ShadedGeometryFlags.js";
@@ -49,6 +48,12 @@ export class ShadedGeometry {
49
48
  */
50
49
  this.material = null;
51
50
 
51
+ /**
52
+ *
53
+ * @type {THREE.Material|null}
54
+ */
55
+ this.depth_material = null;
56
+
52
57
  /**
53
58
  *
54
59
  * @type {number}
@@ -175,6 +180,7 @@ export class ShadedGeometry {
175
180
  && this.draw_method === other.draw_method
176
181
  && this.mode === other.mode
177
182
  && (this.flags & FLAG_SET_EQUALITY) === (other.flags & FLAG_SET_EQUALITY)
183
+ && this.depth_material === other.depth_material
178
184
  ;
179
185
  }
180
186
 
@@ -185,6 +191,7 @@ export class ShadedGeometry {
185
191
  copy(other) {
186
192
  this.geometry = other.geometry;
187
193
  this.material = other.material;
194
+ this.depth_material = other.depth_material;
188
195
  this.draw_method = other.draw_method;
189
196
  this.mode = other.mode;
190
197
  this.flags = other.flags;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Larger bucket sizes provide better cache locality
3
+ * Larger bucket sizes also cause more hanging GC references, as if one matrix element is still held - ENTIRE bucket is still referenced
4
+ * @type {number}
5
+ */
6
+ const ALLOCATOR_BUCKET_CAPACITY = 42;
7
+
8
+ /**
9
+ *
10
+ * @type {ArrayBuffer|null}
11
+ */
12
+ let bucket = null;
13
+
14
+ /**
15
+ *
16
+ * @type {number}
17
+ */
18
+ let bucket_cursor = ALLOCATOR_BUCKET_CAPACITY;
19
+
20
+ const ELEMENT_BYTE_SIZE = 4 * 3;
21
+
22
+ /**
23
+ * custom Float32Array allocator, allocated memory in continuous chunks
24
+ * @returns {Float32Array}
25
+ */
26
+ export function allocate_v3() {
27
+ if (bucket_cursor >= ALLOCATOR_BUCKET_CAPACITY) {
28
+ bucket = new ArrayBuffer(ALLOCATOR_BUCKET_CAPACITY * ELEMENT_BYTE_SIZE);
29
+ bucket_cursor = 0;
30
+ }
31
+
32
+ const result = new Float32Array(bucket, bucket_cursor * ELEMENT_BYTE_SIZE, 3);
33
+
34
+ bucket_cursor++;
35
+
36
+ return result;
37
+ }
@@ -37,5 +37,9 @@ export function build_three_object(sg) {
37
37
  object.castShadow = sg.getFlag(ShadedGeometryFlags.CastShadow);
38
38
  object.receiveShadow = sg.getFlag(ShadedGeometryFlags.ReceiveShadow);
39
39
 
40
+ if (sg.depth_material !== null) {
41
+ object.customDepthMaterial = sg.depth_material;
42
+ }
43
+
40
44
  return object;
41
45
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ * @param {SGroup} pGroup
4
+ * @param {number} iTriIndex
5
+ * @returns {void}
6
+ */
7
+ export function AddTriToGroup(pGroup, iTriIndex) {
8
+ pGroup.pFaceIndices[pGroup.iNrFaces] = iTriIndex;
9
+ pGroup.iNrFaces++;
10
+ }
@@ -0,0 +1,84 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { GROUP_WITH_ANY } from "./constants/GROUP_WITH_ANY.js";
3
+ import { ORIENT_PRESERVING } from "./constants/ORIENT_PRESERVING.js";
4
+ import { AddTriToGroup } from "./AddTriToGroup.js";
5
+
6
+ /**
7
+ *
8
+ * @param {number[]} piTriListIn
9
+ * @param {STriInfo[]} psTriInfos
10
+ * @param {number} iMyTriIndex
11
+ * @param {SGroup} pGroup
12
+ * @return {boolean}
13
+ */
14
+ export function AssignRecur(
15
+ piTriListIn,
16
+ psTriInfos,
17
+ iMyTriIndex,
18
+ pGroup
19
+ ) {
20
+
21
+ // track down vertex
22
+ const iVertRep = pGroup.iVertexRepresentitive;
23
+ const triangle_address = iMyTriIndex * 3;
24
+
25
+ let i = -1;
26
+
27
+ if (piTriListIn[triangle_address] === iVertRep) {
28
+ i = 0;
29
+ } else if (piTriListIn[triangle_address + 1] === iVertRep) {
30
+ i = 1;
31
+ } else if (piTriListIn[triangle_address + 2] === iVertRep) {
32
+ i = 2;
33
+ }
34
+
35
+ assert.greaterThanOrEqual(i, 0);
36
+ assert.lessThan(i, 3);
37
+
38
+ const pMyTriInfo = psTriInfos[iMyTriIndex];
39
+
40
+ // early out
41
+ const sGroups = pMyTriInfo.AssignedGroup;
42
+
43
+ if (sGroups[i] === pGroup) {
44
+ return true;
45
+ } else if (sGroups[i] !== null) {
46
+ return false;
47
+ }
48
+
49
+ if ((pMyTriInfo.iFlag & GROUP_WITH_ANY) !== 0) {
50
+ // first to group with a group-with-anything triangle
51
+ // determines its orientation.
52
+ // This is the only existing order dependency in the code!!
53
+ if (
54
+ sGroups[0] === null &&
55
+ sGroups[1] === null &&
56
+ sGroups[2] === null
57
+ ) {
58
+ pMyTriInfo.iFlag &= (~ORIENT_PRESERVING);
59
+ pMyTriInfo.iFlag |= (pGroup.bOrientPreservering ? ORIENT_PRESERVING : 0);
60
+ }
61
+ }
62
+
63
+ const bOrient = (pMyTriInfo.iFlag & ORIENT_PRESERVING) !== 0;
64
+
65
+ if (bOrient !== pGroup.bOrientPreservering) {
66
+ return false;
67
+ }
68
+
69
+ AddTriToGroup(pGroup, iMyTriIndex);
70
+ sGroups[i] = pGroup;
71
+
72
+ const neigh_indexL = pMyTriInfo.FaceNeighbors[i];
73
+ const neigh_indexR = pMyTriInfo.FaceNeighbors[i > 0 ? (i - 1) : 2];
74
+
75
+ if (neigh_indexL >= 0) {
76
+ AssignRecur(piTriListIn, psTriInfos, neigh_indexL, pGroup);
77
+ }
78
+ if (neigh_indexR >= 0) {
79
+ AssignRecur(piTriListIn, psTriInfos, neigh_indexR, pGroup);
80
+ }
81
+
82
+
83
+ return true;
84
+ }