@woosh/meep-engine 2.40.1 → 2.42.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.
Files changed (75) hide show
  1. package/core/collection/HashMap.d.ts +2 -0
  2. package/core/collection/HashMap.js +22 -0
  3. package/core/geom/3d/apply_mat4_transform_to_v3_array.js +2 -4
  4. package/core/geom/3d/normal/hemioct/encode_unit3_hemioct.js +5 -0
  5. package/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +31 -0
  6. package/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +33 -0
  7. package/core/geom/3d/normal/octahedron/encoding.spec.js +29 -0
  8. package/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.js +28 -0
  9. package/core/geom/3d/topology/struct/BinaryTopology.js +112 -0
  10. package/core/geom/Quaternion.js +14 -0
  11. package/core/math/sign_not_zero.js +8 -0
  12. package/core/parser/simple/SimpleParser.js +3 -86
  13. package/core/parser/simple/readUnsignedInteger.js +66 -0
  14. package/core/parser/simple/skipWhitespace.js +21 -0
  15. package/engine/EngineHarness.js +13 -3
  16. package/engine/asset/AssetDescription.spec.js +27 -0
  17. package/engine/asset/loaders/GLTFAssetLoader.js +5 -3
  18. package/engine/ecs/foliage/ImpostorFoliage.js +4 -0
  19. package/engine/ecs/transform/Transform.js +23 -3
  20. package/engine/graphics/ecs/decal/v2/Decal.d.ts +11 -0
  21. package/engine/graphics/ecs/decal/v2/Decal.js +50 -0
  22. package/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts +8 -0
  23. package/engine/graphics/ecs/decal/v2/FPDecalSystem.js +213 -0
  24. package/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +237 -0
  25. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +8 -1
  26. package/engine/graphics/ecs/mesh-v2/build_three_object.js +4 -0
  27. package/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +22 -7
  28. package/engine/graphics/filter/ImageFilter.js +2 -1
  29. package/engine/graphics/geometry/MikkT/MikkTSpace.js +466 -305
  30. package/engine/graphics/geometry/MikkT/MikkTSpace.spec.js +7 -1
  31. package/engine/{asset/loaders/geometry/geometry → graphics/geometry/buffered}/computeBufferAttributeHash.js +1 -1
  32. package/engine/{asset/loaders/geometry/geometry → graphics/geometry/buffered}/computeGeometryEquality.js +2 -2
  33. package/engine/{asset/loaders/geometry/geometry → graphics/geometry/buffered}/computeGeometryHash.js +1 -1
  34. package/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +2 -2
  35. package/engine/graphics/impostors/card_cluster/FacePlaneAssignment.js +30 -0
  36. package/engine/graphics/impostors/card_cluster/README.md +13 -0
  37. package/engine/graphics/impostors/octahedral/ImpostorBaker.js +345 -0
  38. package/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +10 -0
  39. package/engine/graphics/impostors/octahedral/ImpostorDescription.js +69 -0
  40. package/engine/graphics/impostors/octahedral/README.md +30 -0
  41. package/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere.js +45 -0
  42. package/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere_radius_only.js +37 -0
  43. package/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +117 -0
  44. package/engine/graphics/impostors/octahedral/grid/HemiOctahedralUvEncoder.js +20 -0
  45. package/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +25 -0
  46. package/engine/graphics/impostors/octahedral/grid/UvEncoder.js +21 -0
  47. package/engine/graphics/impostors/octahedral/prototypeBaker.js +237 -0
  48. package/engine/graphics/impostors/octahedral/shader/BakeShaderStandard.js +196 -0
  49. package/engine/graphics/impostors/octahedral/shader/ImpostorShaderStandard.js +306 -0
  50. package/engine/graphics/impostors/octahedral/shader/ImpostorShaderV0.js +349 -0
  51. package/engine/graphics/impostors/octahedral/shader/ImpostorShaderV1.js +74 -0
  52. package/engine/graphics/impostors/octahedral/shader/glsl/common.glsl +206 -0
  53. package/engine/graphics/impostors/octahedral/shader/glsl/v1/common.glsl +209 -0
  54. package/engine/graphics/impostors/octahedral/shader/glsl/v1/flagment.glsl +80 -0
  55. package/engine/graphics/impostors/octahedral/shader/glsl/v1/vertex.glsl +350 -0
  56. package/engine/graphics/micron/convert_three_object_to_micron.js +2 -2
  57. package/engine/graphics/micron/plugin/MicronRenderPlugin.js +2 -2
  58. package/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +1 -1
  59. package/engine/graphics/particles/node-based/codegen/CodeGenerator.js +1 -1
  60. package/engine/graphics/particles/node-based/nodes/noise/CurlNoiseNode.js +1 -1
  61. package/engine/graphics/render/forward_plus/LightManager.js +1 -1
  62. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +1 -3
  63. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +2 -1
  64. package/engine/graphics/render/forward_plus/model/Decal.js +19 -2
  65. package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +32 -10
  66. package/engine/graphics/shaders/ScreenSpaceQuadShader.js +4 -14
  67. package/engine/graphics/shaders/glsl_gen_swizzled_read.js +39 -0
  68. package/engine/graphics/texture/sampler/Sampler2D.js +10 -10
  69. package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +117 -11
  70. package/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +66 -0
  71. package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +2 -2
  72. package/engine/ui/GUIEngine.js +8 -1
  73. package/package.json +1 -1
  74. package/view/tooltip/gml/parser/readReferenceToken.js +1 -1
  75. package/engine/asset/GameAssetManager.js +0 -137
@@ -63,9 +63,29 @@ export class Transform {
63
63
  this.flags = FLAGS_DEFAULT;
64
64
 
65
65
  // watch changes
66
- this.position.onChanged.add(this.__handle_component_change, this);
67
- this.rotation.onChanged.add(this.__handle_component_change, this);
68
- this.scale.onChanged.add(this.__handle_component_change, this);
66
+ this.subscribeAllChanges(this.__handle_component_change, this);
67
+ }
68
+
69
+ /**
70
+ *
71
+ * @param {function} handler
72
+ * @param {*} [thisArg]
73
+ */
74
+ subscribeAllChanges(handler, thisArg) {
75
+ this.position.onChanged.add(handler, thisArg);
76
+ this.rotation.onChanged.add(handler, thisArg);
77
+ this.scale.onChanged.add(handler, thisArg);
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @param {function} handler
83
+ * @param {*} [thisArg]
84
+ */
85
+ unsubscribeAllChanges(handler, thisArg) {
86
+ this.position.onChanged.remove(handler, thisArg);
87
+ this.rotation.onChanged.remove(handler, thisArg);
88
+ this.scale.onChanged.scale(handler, thisArg);
69
89
  }
70
90
 
71
91
  /**
@@ -0,0 +1,11 @@
1
+ export class Decal {
2
+ /**
3
+ * Path to image
4
+ */
5
+ uri: string
6
+
7
+ /**
8
+ * Draw order, higher values will be drawn on top of lower values when there's an overlap
9
+ */
10
+ priority: number
11
+ }
@@ -0,0 +1,50 @@
1
+ export class Decal {
2
+ constructor() {
3
+ /**
4
+ * Asset URL
5
+ * @type {string}
6
+ */
7
+ this.uri = "";
8
+
9
+ /**
10
+ * Controls draw order
11
+ * @type {number}
12
+ */
13
+ this.priority = 0;
14
+
15
+ /**
16
+ * Internal transient reference to loaded asset
17
+ * @type {Sampler2D|null}
18
+ * @private
19
+ */
20
+ this.__cached_sampler = null;
21
+ /**
22
+ *
23
+ * @type {String|null}
24
+ * @private
25
+ */
26
+ this.__cached_uri = null;
27
+ }
28
+
29
+ toJSON() {
30
+ return {
31
+ uri: this.uri,
32
+ priority: this.priority
33
+ };
34
+ }
35
+
36
+ fromJSON({
37
+ uri, priority = 0
38
+ }) {
39
+ this.uri = uri;
40
+ this.priority = priority;
41
+
42
+ if (uri !== this.__cached_uri) {
43
+ // reset sampler
44
+ this.__cached_sampler = null;
45
+ this.__cached_uri = null;
46
+ }
47
+ }
48
+ }
49
+
50
+ Decal.typeName = 'Decal';
@@ -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,213 @@
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
+
12
+ const placeholder_texture = Sampler2D.uint8(4, 1, 1);
13
+ placeholder_texture.data.fill(255);
14
+
15
+ class Context extends SystemEntityContext {
16
+ constructor() {
17
+ super();
18
+
19
+ /**
20
+ *
21
+ * @type {FPDecal|null}
22
+ * @private
23
+ */
24
+ this.__fp_decal = null;
25
+ }
26
+
27
+ /**
28
+ * @return {ForwardPlusRenderingPlugin}
29
+ * @private
30
+ */
31
+ getPlugin() {
32
+ return this.system.__fp_plugin.getValue();
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @returns {Transform}
38
+ */
39
+ getTransform() {
40
+ return this.components[1];
41
+ }
42
+
43
+ __update_transform() {
44
+ /**
45
+ *
46
+ * @type {Transform}
47
+ */
48
+ const transform = this.getTransform();
49
+
50
+ this.__fp_decal.setTransform(transform.matrix);
51
+ }
52
+
53
+ async __load_texture() {
54
+
55
+ /**
56
+ *
57
+ * @type {Decal}
58
+ */
59
+ const decal_spec = this.components[0];
60
+
61
+ const _uri = decal_spec.uri;
62
+
63
+ if (decal_spec.__cached_sampler !== null && decal_spec.__cached_uri === _uri) {
64
+ // cached asset is still relevant
65
+ return;
66
+ }
67
+
68
+
69
+ const loaded_texture = await this.system.internal_loadTexture(_uri);
70
+
71
+ decal_spec.__cached_sampler = loaded_texture;
72
+ decal_spec.__cached_uri = _uri;
73
+ }
74
+
75
+ link() {
76
+ const plugin = this.getPlugin();
77
+
78
+ const lm = plugin.getLightManager();
79
+
80
+ const fpDecal = new FPDecal();
81
+
82
+ this.__fp_decal = fpDecal;
83
+
84
+
85
+ this.__update_transform();
86
+
87
+ const transform = this.getTransform();
88
+ transform.subscribeAllChanges(this.__update_transform, this);
89
+
90
+ /**
91
+ *
92
+ * @type {Decal}
93
+ */
94
+ const decal_spec = this.components[0];
95
+
96
+ this.__load_texture().then(() => {
97
+
98
+ if (!this.__is_linked) {
99
+ // not linked anymore
100
+ return;
101
+ }
102
+
103
+ const sampler = decal_spec.__cached_sampler;
104
+
105
+ if (sampler === null) {
106
+ return;
107
+ }
108
+
109
+ fpDecal.texture_diffuse = sampler;
110
+
111
+ if (this.__fp_decal === fpDecal) {
112
+ lm.addLight(fpDecal);
113
+ }
114
+ });
115
+
116
+
117
+ super.link();
118
+ }
119
+
120
+ unlink() {
121
+
122
+ this.getPlugin()
123
+ .getLightManager()
124
+ .removeLight(this.__fp_decal);
125
+
126
+ this.__fp_decal = null;
127
+
128
+ const transform = this.getTransform();
129
+ transform.subscribeAllChanges(this.__update_transform, this);
130
+
131
+ super.unlink();
132
+ }
133
+ }
134
+
135
+ export class FPDecalSystem extends AbstractContextSystem {
136
+ /**
137
+ *
138
+ * @param {Engine} engine
139
+ */
140
+ constructor(engine) {
141
+ super(Context);
142
+
143
+ this.dependencies = [Decal, Transform];
144
+
145
+ /**
146
+ *
147
+ * @type {Map<string, Sampler2D>}
148
+ * @private
149
+ */
150
+ this.__texture_cache = new Map();
151
+
152
+ /**
153
+ *
154
+ * @type {AssetManager}
155
+ * @private
156
+ */
157
+ this.__assets = engine.assetManager;
158
+
159
+ /**
160
+ *
161
+ * @type {Engine}
162
+ * @private
163
+ */
164
+ this.__engine = engine;
165
+
166
+ /**
167
+ *
168
+ * @type {Reference<ForwardPlusRenderingPlugin>|null}
169
+ * @private
170
+ */
171
+ this.__fp_plugin = Reference.NULL;
172
+ }
173
+
174
+ /**
175
+ *
176
+ * @param {string} uri
177
+ * @returns {Promise<void>}
178
+ */
179
+ async internal_loadTexture(uri) {
180
+ const cached = this.__texture_cache.get(uri);
181
+
182
+ if (cached !== undefined) {
183
+ return cached;
184
+ }
185
+
186
+ const asset = await this.__assets.promise(uri, GameAssetType.Image);
187
+
188
+ // check cache again, in case another request has succeeded
189
+ const cached_v2 = this.__texture_cache.get(uri);
190
+
191
+ if (cached_v2 !== undefined) {
192
+ return cached_v2;
193
+ }
194
+
195
+ const sampler = asset.create();
196
+
197
+ this.__texture_cache.set(uri, sampler);
198
+
199
+ return sampler;
200
+ }
201
+
202
+ async startup(em, ready_callback, error_callback) {
203
+ this.__fp_plugin = await this.__engine.plugins.acquire(ForwardPlusRenderingPlugin);
204
+
205
+ super.startup(em, ready_callback, error_callback);
206
+ }
207
+
208
+ shutdown(em, ready_callback, error_callback) {
209
+ this.__fp_plugin.release();
210
+
211
+ super.shutdown(em, ready_callback, error_callback);
212
+ }
213
+ }
@@ -0,0 +1,237 @@
1
+ import { EngineHarness } from "../../../../EngineHarness.js";
2
+ import { FPDecalSystem } from "./FPDecalSystem.js";
3
+ import EntityBuilder 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 Quaternion from "../../../../../core/geom/Quaternion.js";
9
+ import { randomFromArray } from "../../../../../core/math/random/randomFromArray.js";
10
+ import { BehaviorComponent } from "../../../../intelligence/behavior/ecs/BehaviorComponent.js";
11
+ import { RotationBehavior } from "../../../../../../model/game/util/behavior/RotationBehavior.js";
12
+ import { BehaviorSystem } from "../../../../intelligence/behavior/ecs/BehaviorSystem.js";
13
+
14
+ const decal_urls = `data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_13_t.png
15
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_01_t.png
16
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_02_t.png
17
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_03_t.png
18
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_04_t.png
19
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_05_t.png
20
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_06_t.png
21
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_07_t.png
22
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_08_t.png
23
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_09_t.png
24
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_10_t.png
25
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_11_t.png
26
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_12_t.png
27
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_13_t.png
28
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_14_t.png
29
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_01_t.png
30
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_02_t.png
31
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_03_t.png
32
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_04_t.png
33
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_05_t.png
34
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_06_t.png
35
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_07_t.png
36
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_08_t.png
37
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_09_t.png
38
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_10_b.png
39
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_11_t.png
40
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/bag_12_t.png
41
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_01_t.png
42
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_02_t.png
43
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_03_t.png
44
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_04_t.png
45
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_05_t.png
46
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_06_t.png
47
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_07_t.png
48
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_08_t.png
49
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_09_t.png
50
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_10_t.png
51
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_11_t.png
52
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_12_t.png
53
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_13_t.png
54
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_14_t.png
55
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_15_t.png
56
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_16_t.png
57
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/book_17_t.png
58
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_01_t.png
59
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_02_t.png
60
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_03_t.png
61
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_04_t.png
62
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_05_t.png
63
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_06_t.png
64
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_07_t.png
65
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_08_t.png
66
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_09_t.png
67
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_10_t.png
68
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_11_t.png
69
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/orb_12_t.png
70
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_01_t.png
71
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_02_t.png
72
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_03_t.png
73
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_04_t.png
74
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_05_t.png
75
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_06_t.png
76
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_07_t.png
77
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_08_t.png
78
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_09_t.png
79
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_10_t.png
80
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_11_t.png
81
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/potion_12_t.png
82
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_01_t.png
83
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_02_t.png
84
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_03_t.png
85
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_04_t.png
86
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_05_t.png
87
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_06_t.png
88
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_07_t.png
89
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_08_t.png
90
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_09_t.png
91
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_10_t.png
92
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_11_t.png
93
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/rune_12_t.png
94
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_01_t.png
95
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_02_t.png
96
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_03_t.png
97
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_04_t.png
98
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_05_t.png
99
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_06_t.png
100
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_07_t.png
101
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_08_t.png
102
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_09_t.png
103
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_10_t.png
104
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_11_t.png
105
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_12_t.png
106
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/scroll_13_t.png
107
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_01_t.png
108
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_02_t.png
109
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_03_t.png
110
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_04_t.png
111
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_05_t.png
112
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_06_t.png
113
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_07_t.png
114
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_08_t.png
115
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_09_t.png
116
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_10_t.png
117
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_11_t.png
118
+ data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_12_t.png
119
+ data/textures/icons/sci-fi-nathan/v6/Proc normal_3.png
120
+ data/textures/icons/sci-fi-nathan/v6/Proc strong_1.png
121
+ data/textures/icons/sci-fi-nathan/v6/Proc strong_2.png
122
+ data/textures/icons/sci-fi-nathan/v6/Proc strong_3.png
123
+ data/textures/icons/sci-fi-nathan/v6/Proc very strong_1.png
124
+ data/textures/icons/sci-fi-nathan/v6/Proc very strong_2.png
125
+ data/textures/icons/sci-fi-nathan/v6/Proc very strong_3.png
126
+ data/textures/icons/sci-fi-nathan/v6/Proc very weak_1.png
127
+ data/textures/icons/sci-fi-nathan/v6/Proc very weak_2.png
128
+ data/textures/icons/sci-fi-nathan/v6/Proc very weak_3.png
129
+ data/textures/icons/sci-fi-nathan/v6/Proc weak_1.png
130
+ data/textures/icons/sci-fi-nathan/v6/Proc weak_2.png
131
+ data/textures/icons/sci-fi-nathan/v6/Proc weak_3.png
132
+ data/textures/icons/sci-fi-nathan/v6/Core normal_1.png
133
+ data/textures/icons/sci-fi-nathan/v6/Core normal_2.png
134
+ data/textures/icons/sci-fi-nathan/v6/Core normal_3.png
135
+ data/textures/icons/sci-fi-nathan/v6/Core strong_1.png
136
+ data/textures/icons/sci-fi-nathan/v6/Core strong_2.png
137
+ data/textures/icons/sci-fi-nathan/v6/Core strong_3.png
138
+ data/textures/icons/sci-fi-nathan/v6/Core very strong_1.png
139
+ data/textures/icons/sci-fi-nathan/v6/Core very strong_2.png
140
+ data/textures/icons/sci-fi-nathan/v6/Core very strong_3.png
141
+ data/textures/icons/sci-fi-nathan/v6/Core very weak_1.png
142
+ data/textures/icons/sci-fi-nathan/v6/Core very weak_2.png
143
+ data/textures/icons/sci-fi-nathan/v6/Core very weak_3.png
144
+ data/textures/icons/sci-fi-nathan/v6/Core weak_1.png
145
+ data/textures/icons/sci-fi-nathan/v6/Core weak_2.png
146
+ data/textures/icons/sci-fi-nathan/v6/Core weak_3.png
147
+ data/textures/icons/sci-fi-nathan/v6/Memory normal_1.png
148
+ data/textures/icons/sci-fi-nathan/v6/Memory normal_2.png
149
+ data/textures/icons/sci-fi-nathan/v6/Memory normal_3.png
150
+ data/textures/icons/sci-fi-nathan/v6/Memory strong_1.png
151
+ data/textures/icons/sci-fi-nathan/v6/Memory strong_2.png
152
+ data/textures/icons/sci-fi-nathan/v6/Memory strong_3.png
153
+ data/textures/icons/sci-fi-nathan/v6/Memory very strong_1.png
154
+ data/textures/icons/sci-fi-nathan/v6/Memory very strong_2.png
155
+ data/textures/icons/sci-fi-nathan/v6/Memory very strong_3.png
156
+ data/textures/icons/sci-fi-nathan/v6/Memory very weak_1.png
157
+ data/textures/icons/sci-fi-nathan/v6/Memory very weak_2.png
158
+ data/textures/icons/sci-fi-nathan/v6/Memory very weak_3.png
159
+ data/textures/icons/sci-fi-nathan/v6/Memory weak_1.png
160
+ data/textures/icons/sci-fi-nathan/v6/Memory weak_2.png
161
+ data/textures/icons/sci-fi-nathan/v6/Memory weak_3.png
162
+ data/textures/icons/sci-fi-nathan/v6/Module normal_1.png
163
+ data/textures/icons/sci-fi-nathan/v6/Module normal_2.png
164
+ data/textures/icons/sci-fi-nathan/v6/Module normal_3.png
165
+ data/textures/icons/sci-fi-nathan/v6/Module strong_1.png
166
+ data/textures/icons/sci-fi-nathan/v6/Module strong_2.png
167
+ data/textures/icons/sci-fi-nathan/v6/Module strong_3.png
168
+ data/textures/icons/sci-fi-nathan/v6/Module very strong_1.png
169
+ data/textures/icons/sci-fi-nathan/v6/Module very strong_2.png
170
+ data/textures/icons/sci-fi-nathan/v6/Module very strong_3.png
171
+ data/textures/icons/sci-fi-nathan/v6/Module very weak_1.png
172
+ data/textures/icons/sci-fi-nathan/v6/Module very weak_2.png
173
+ data/textures/icons/sci-fi-nathan/v6/Module very weak_3.png
174
+ data/textures/icons/sci-fi-nathan/v6/Module weak_1.png
175
+ data/textures/icons/sci-fi-nathan/v6/Module weak_2.png
176
+ data/textures/icons/sci-fi-nathan/v6/Module weak_3.png
177
+ data/textures/icons/sci-fi-nathan/v6/Power normal_1.png
178
+ data/textures/icons/sci-fi-nathan/v6/Power normal_2.png
179
+ data/textures/icons/sci-fi-nathan/v6/Power normal_3.png
180
+ data/textures/icons/sci-fi-nathan/v6/Power strong_1.png
181
+ data/textures/icons/sci-fi-nathan/v6/Power strong_2.png
182
+ data/textures/icons/sci-fi-nathan/v6/Power strong_3.png
183
+ data/textures/icons/sci-fi-nathan/v6/Power very strong_1.png
184
+ data/textures/icons/sci-fi-nathan/v6/Power very strong_2.png
185
+ data/textures/icons/sci-fi-nathan/v6/Power very strong_3.png
186
+ data/textures/icons/sci-fi-nathan/v6/Power very weak_1.png
187
+ data/textures/icons/sci-fi-nathan/v6/Power very weak_2.png
188
+ data/textures/icons/sci-fi-nathan/v6/Power very weak_3.png
189
+ data/textures/icons/sci-fi-nathan/v6/Power weak_1.png
190
+ data/textures/icons/sci-fi-nathan/v6/Power weak_2.png
191
+ data/textures/icons/sci-fi-nathan/v6/Power weak_3.png
192
+ data/textures/icons/sci-fi-nathan/v6/Proc normal_1.png
193
+ data/textures/icons/sci-fi-nathan/v6/Proc normal_2.png
194
+ data/textures/utility/sampling-test.png`
195
+ .split('\n')
196
+ .map(a => a.trim());
197
+
198
+ /**
199
+ *
200
+ * @param {Engine} engine
201
+ */
202
+ async function main(engine) {
203
+
204
+ await EngineHarness.buildBasics({
205
+ engine
206
+ });
207
+
208
+ const random = seededRandom();
209
+
210
+ for (let i = 0; i < 100; i++) {
211
+ const decal = new Decal();
212
+
213
+ decal.uri = randomFromArray(random, decal_urls);
214
+
215
+ new EntityBuilder()
216
+ .add(Transform.fromJSON({
217
+ position: { x: randomFloatBetween(random, 0, 10), y: 0, z: randomFloatBetween(random, 0, 10) },
218
+ rotation: Quaternion.random(random)
219
+ }))
220
+ .add(decal)
221
+ .add(BehaviorComponent.fromOne(RotationBehavior.fromJSON({
222
+ speed: 1
223
+ })))
224
+ .build(engine.entityManager.dataset);
225
+ }
226
+
227
+ }
228
+
229
+ new EngineHarness()
230
+ .initialize({
231
+ configuration(config, engine) {
232
+
233
+ config.addSystem(new FPDecalSystem(engine));
234
+ config.addSystem(new BehaviorSystem(engine))
235
+
236
+ }
237
+ }).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;
@@ -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
  }
@@ -2,6 +2,22 @@ import { EntityNode } from "../../../ecs/parent/EntityNode.js";
2
2
  import { Transform } from "../../../ecs/transform/Transform.js";
3
3
  import { ShadedGeometry } from "./ShadedGeometry.js";
4
4
 
5
+ /**
6
+ *
7
+ * @param {Transform} transform
8
+ * @param {THREE.Object3D} three_object
9
+ */
10
+ function copy_three_transform(transform, three_object) {
11
+
12
+ // copy object transform
13
+ transform.position.copy(three_object.position);
14
+ transform.scale.copy(three_object.scale);
15
+ transform.rotation.copy(three_object.quaternion);
16
+
17
+ //
18
+ transform.matrix.set(three_object.matrix.elements);
19
+ }
20
+
5
21
  /**
6
22
  *
7
23
  * @param {THREE.Object3D} root
@@ -13,16 +29,15 @@ export function three_object_to_entity_composition(root) {
13
29
  const node_transform = node.transform;
14
30
 
15
31
  // copy object transform
16
- node_transform.position.copy(root.position);
17
- node_transform.scale.copy(root.scale);
18
- node_transform.rotation.copy(root.quaternion);
19
-
20
- //
21
- node_transform.matrix.set(root.matrix.elements);
32
+ copy_three_transform(node_transform, root);
22
33
 
23
34
  const entity = node.entity;
24
35
 
25
- entity.add(new Transform());
36
+ const transform = new Transform();
37
+ // initialize world transform
38
+ transform.fromMatrix4(root.matrixWorld.elements);
39
+
40
+ entity.add(transform);
26
41
 
27
42
  if (root.isMesh) {
28
43
  if (root.isSkinnedMesh) {
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
 
6
- import { LinearFilter, Mesh, OrthographicCamera, Scene, ShaderMaterial, WebGLRenderTarget } from 'three';
6
+ import { DoubleSide, LinearFilter, Mesh, OrthographicCamera, Scene, ShaderMaterial, WebGLRenderTarget } from 'three';
7
7
  import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js";
8
8
  import { FULL_SCREEN_QUAD_VERTEX_SHADER } from "../FULL_SCREEN_QUAD_VERTEX_SHADER.js";
9
9
 
@@ -41,6 +41,7 @@ function processTexture(
41
41
  material.fog = false;
42
42
  material.uniformsNeedUpdate = true;
43
43
  material.needsUpdate = true;
44
+ material.side = DoubleSide;
44
45
 
45
46
  const quad = new Mesh(FULL_SCREEN_TRIANGLE_GEOMETRY, material);
46
47