@woosh/meep-engine 2.46.28 → 2.46.30
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/editor/Editor.js +793 -0
- package/editor/SelectionVisualizer.js +148 -0
- package/editor/actions/concrete/ActionUpdateTexture.js +21 -0
- package/editor/actions/concrete/ArrayCopyAction.js +39 -0
- package/editor/actions/concrete/ComponentAddAction.js +47 -0
- package/editor/actions/concrete/ComponentRemoveAction.js +38 -0
- package/editor/actions/concrete/EntityCreateAction.js +47 -0
- package/editor/actions/concrete/EntityRemoveAction.js +51 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.js +118 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.spec.js +30 -0
- package/editor/actions/concrete/ModifyPatchTextureArray2DAction.js +182 -0
- package/editor/actions/concrete/PaintTerrainOverlayAction.js +45 -0
- package/editor/actions/concrete/PatchTerrainHeightAction.js +67 -0
- package/editor/actions/concrete/PatchTerrainTextureAction.js +152 -0
- package/editor/actions/concrete/SelectionAddAction.js +36 -0
- package/editor/actions/concrete/SelectionClearAction.js +22 -0
- package/editor/actions/concrete/SelectionRemoveAction.js +30 -0
- package/editor/actions/concrete/TransformModifyAction.js +46 -0
- package/editor/actions/concrete/WriteGridValueAction.js +46 -0
- package/editor/ecs/EditorEntity.js +12 -0
- package/editor/ecs/EditorEntitySystem.js +14 -0
- package/editor/ecs/component/FieldDescriptor.js +34 -0
- package/editor/ecs/component/FieldValueAdapter.js +20 -0
- package/editor/ecs/component/TypeEditor.js +33 -0
- package/editor/ecs/component/TypeSchema.d.ts +38 -0
- package/editor/ecs/component/createFieldEditor.js +92 -0
- package/editor/ecs/component/createObjectEditor.js +361 -0
- package/editor/ecs/component/editors/ColorEditor.js +39 -0
- package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
- package/editor/ecs/component/editors/ImagePathEditor.js +82 -0
- package/editor/ecs/component/editors/LargeStrongEditor.js +107 -0
- package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
- package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
- package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
- package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
- package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
- package/editor/ecs/component/editors/Sampler2DEditor.js +221 -0
- package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
- package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
- package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
- package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
- package/editor/ecs/component/editors/common/noEditor.js +9 -0
- package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
- package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +225 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackSetEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
- package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
- package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +95 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
- package/editor/ecs/component/editors/geom/QuaternionEditor.js +63 -0
- package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
- package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
- package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
- package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
- package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
- package/editor/ecs/component/editors/primitive/FunctionEditor.js +29 -0
- package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
- package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
- package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
- package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
- package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
- package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
- package/editor/ecs/component/editors/three/TextureEditor.js +112 -0
- package/editor/ecs/component/findNearestRegisteredType.js +59 -0
- package/editor/ecs/component/prototypeObjectEditor.js +379 -0
- package/editor/enableEditor.js +85 -0
- package/editor/library/MeshLibrary.js +33 -0
- package/editor/process/DisableGameUIProcess.js +43 -0
- package/editor/process/EditorProcess.js +35 -0
- package/editor/process/ObstacleGridDisplayProcess.js +120 -0
- package/editor/process/ProcessEngine.js +123 -0
- package/editor/process/SymbolicDisplayProcess.js +132 -0
- package/editor/process/symbolic/ComponentSymbolicDisplay.js +34 -0
- package/editor/process/symbolic/SymbolicDisplayInternalAPI.js +159 -0
- package/editor/process/symbolic/buildThreeJSHelperEntity.js +36 -0
- package/editor/process/symbolic/make3DSymbolicDisplay.js +91 -0
- package/editor/process/symbolic/makeCameraSymbolicDisplay.js +32 -0
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +176 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/process/symbolic/makeHelperSphereGeometry.js +73 -0
- package/editor/process/symbolic/makeLightSymbolicDisplay.js +77 -0
- package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.js +146 -0
- package/editor/process/symbolic/makePathSymbolicDisplay.js +105 -0
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +74 -0
- package/editor/process/symbolic/makeSocketsSymbolicDisplay.js +153 -0
- package/editor/process/symbolic/makeSolidArrowGeometry.js +391 -0
- package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.js +89 -0
- package/editor/process/symbolic/makeStoryTriggerSetAreaDisplay.js +114 -0
- package/editor/process/symbolic/synchronizeTransform.js +50 -0
- package/editor/tools/FoliagePaintTool.js +168 -0
- package/editor/tools/GridPaintTool.js +247 -0
- package/editor/tools/SelectionTool.js +407 -0
- package/editor/tools/TopDownCameraControlTool.js +59 -0
- package/editor/tools/TransformTool.js +370 -0
- package/editor/tools/engine/Tool.js +121 -0
- package/editor/tools/engine/ToolEngine.js +193 -0
- package/editor/tools/engine/ToolState.js +9 -0
- package/editor/tools/engine/ToolStateMachine.js +53 -0
- package/editor/tools/paint/TerrainHeightPaintTool.js +297 -0
- package/editor/tools/paint/TerrainPaintTool.js +211 -0
- package/editor/tools/paint/TerrainTexturePaintTool.js +193 -0
- package/editor/tools/paint/prototypeTerrainEditor.js +135 -0
- package/editor/tools/v2/BlenderCameraOrientationGizmo.d.ts +50 -0
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +500 -0
- package/editor/tools/v2/TransformControls.d.ts +20 -0
- package/editor/tools/v2/TransformControls.js +1782 -0
- package/editor/tools/v2/prototypeTransformControls.js +92 -0
- package/editor/view/EditorView.js +462 -0
- package/editor/view/GridPickCoordinateView.js +88 -0
- package/editor/view/ecs/ComponentControlFactory.js +48 -0
- package/editor/view/ecs/ComponentControlView.js +214 -0
- package/editor/view/ecs/EntityEditor.js +258 -0
- package/editor/view/ecs/EntityList.js +258 -0
- package/editor/view/ecs/components/BlackboardController.js +50 -0
- package/editor/view/ecs/components/DatGuiController.js +216 -0
- package/editor/view/ecs/components/FogOfWarController.js +78 -0
- package/editor/view/ecs/components/FogOfWarRevealerController.js +44 -0
- package/editor/view/ecs/components/GeneratedArmyController.js +42 -0
- package/editor/view/ecs/components/GridObstacleController.js +72 -0
- package/editor/view/ecs/components/GridPositionController.js +40 -0
- package/editor/view/ecs/components/HeadsUpDisplayController.js +30 -0
- package/editor/view/ecs/components/HighlightController.js +47 -0
- package/editor/view/ecs/components/MeshController.js +125 -0
- package/editor/view/ecs/components/PathFollowerController.js +87 -0
- package/editor/view/ecs/components/TagController.js +80 -0
- package/editor/view/ecs/components/TerrainController.js +225 -0
- package/editor/view/ecs/components/TransformController.js +103 -0
- package/editor/view/ecs/components/UnitShopController.js +112 -0
- package/editor/view/ecs/components/army/ArmyController.js +130 -0
- package/editor/view/ecs/components/color/GaugeView.js +107 -0
- package/editor/view/ecs/components/common/AutoCanvasView.js +53 -0
- package/editor/view/ecs/components/common/LineView.js +17 -0
- package/editor/view/ecs/components/common/NumberController.js +112 -0
- package/editor/view/ecs/components/common/NumericIntervalController.js +64 -0
- package/editor/view/ecs/components/gui/GUIElementController.js +117 -0
- package/editor/view/ecs/components/items/ItemContainerController.js +132 -0
- package/editor/view/ecs/components/items/ItemContainerController.stories.js +50 -0
- package/editor/view/ecs/components/items/ItemController.js +52 -0
- package/editor/view/ecs/components/particles/ColorParameterLUTController.js +444 -0
- package/editor/view/ecs/components/particles/ParameterTrackController.js +51 -0
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +213 -0
- package/editor/view/ecs/components/particles/ParticleLayerController.js +213 -0
- package/editor/view/ecs/components/particles/ScalarParameterLUTController.js +401 -0
- package/editor/view/ecs/components/sockets/AttachmentSocketsController.js +51 -0
- package/editor/view/ecs/components/sound/SoundEmitterController.js +137 -0
- package/editor/view/ecs/components/story/StoryTriggerSetController.js +214 -0
- package/editor/view/ecs/components/unit/AuraController.js +45 -0
- package/editor/view/library/MeshLibraryView.js +164 -0
- package/editor/view/node-graph/NodeGraphEditorView.js +170 -0
- package/editor/view/node-graph/NodeGraphView.js +453 -0
- package/editor/view/node-graph/NodeView.js +135 -0
- package/editor/view/node-graph/PortView.js +69 -0
- package/editor/view/process/ProcessView.js +63 -0
- package/editor/view/tools/ToolSettingsView.js +143 -0
- package/editor/view/tools/ToolView.js +58 -0
- package/package.json +2 -1
- package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +6 -1
- package/src/core/geom/3d/aabb/aabb3_matrix4_project.js +1 -1
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts +9 -0
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +148 -9
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +21 -1
- package/src/engine/graphics/render/forward_plus/LightManager.js +0 -60
- package/src/engine/graphics/render/forward_plus/LightRenderMetadata.js +1 -3
- package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.d.ts +0 -3
- package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +0 -11
|
@@ -11,21 +11,54 @@ import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
|
11
11
|
import { assert } from "../../../../../core/assert.js";
|
|
12
12
|
import { AsyncLoadingCache } from "../../../../../core/collection/map/AsyncLoadingCache.js";
|
|
13
13
|
import { sampler2d_to_uint8_RGBA } from "../../../texture/sampler/sampler2d_to_uint8_RGBA.js";
|
|
14
|
+
import { returnTrue } from "../../../../../core/function/Functions.js";
|
|
15
|
+
import {
|
|
16
|
+
ExplicitBinaryBoundingVolumeHierarchy
|
|
17
|
+
} from "../../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
18
|
+
import { bvh_query_leaves_ray } from "../../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
|
|
19
|
+
import { ray3_array_apply_matrix4 } from "../../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
|
|
20
|
+
import { aabb3_intersects_ray } from "../../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
|
|
21
|
+
import { ray3_array_compose } from "../../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
22
|
+
import { mat4 } from "gl-matrix";
|
|
23
|
+
import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
|
|
24
|
+
import { EBBVHLeafProxy } from "../../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
|
|
25
|
+
import { aabb3_matrix4_project } from "../../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
14
26
|
|
|
15
27
|
const placeholder_texture = Sampler2D.uint8(4, 1, 1);
|
|
16
28
|
placeholder_texture.data.fill(255);
|
|
17
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @readonly
|
|
32
|
+
* @type {Float32Array}
|
|
33
|
+
*/
|
|
34
|
+
const scratch_ray_0 = new Float32Array(6);
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @type {Float32Array|mat4}
|
|
40
|
+
*/
|
|
41
|
+
const scratch_m4 = new Float32Array(16);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {Float32Array}
|
|
46
|
+
*/
|
|
47
|
+
const AABB_UNIT_CUBE = new Float32Array([
|
|
48
|
+
-0.5, -0.5, -0.5,
|
|
49
|
+
0.5, 0.5, 0.5
|
|
50
|
+
]);
|
|
51
|
+
|
|
18
52
|
class Context extends SystemEntityContext {
|
|
19
|
-
constructor() {
|
|
20
|
-
super();
|
|
21
53
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @type {FPDecal|null}
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
__fp_decal = null;
|
|
60
|
+
|
|
61
|
+
#bvh_leaf = new EBBVHLeafProxy();
|
|
29
62
|
|
|
30
63
|
/**
|
|
31
64
|
* @return {ForwardPlusRenderingPlugin}
|
|
@@ -51,6 +84,10 @@ class Context extends SystemEntityContext {
|
|
|
51
84
|
const transform = this.getTransform();
|
|
52
85
|
|
|
53
86
|
this.__fp_decal.setTransform(transform.matrix);
|
|
87
|
+
|
|
88
|
+
aabb3_matrix4_project(this.#bvh_leaf.bounds, AABB_UNIT_CUBE, transform.matrix);
|
|
89
|
+
|
|
90
|
+
this.#bvh_leaf.write_bounds();
|
|
54
91
|
}
|
|
55
92
|
|
|
56
93
|
async __load_texture() {
|
|
@@ -135,6 +172,7 @@ class Context extends SystemEntityContext {
|
|
|
135
172
|
}
|
|
136
173
|
});
|
|
137
174
|
|
|
175
|
+
this.#bvh_leaf.link(this.system.bvh, this.entity);
|
|
138
176
|
|
|
139
177
|
super.link();
|
|
140
178
|
}
|
|
@@ -150,6 +188,8 @@ class Context extends SystemEntityContext {
|
|
|
150
188
|
const transform = this.getTransform();
|
|
151
189
|
transform.subscribeAllChanges(this.__update_transform, this);
|
|
152
190
|
|
|
191
|
+
this.#bvh_leaf.unlink();
|
|
192
|
+
|
|
153
193
|
super.unlink();
|
|
154
194
|
}
|
|
155
195
|
}
|
|
@@ -160,6 +200,8 @@ class Context extends SystemEntityContext {
|
|
|
160
200
|
*
|
|
161
201
|
*/
|
|
162
202
|
export class FPDecalSystem extends AbstractContextSystem {
|
|
203
|
+
bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
204
|
+
|
|
163
205
|
/**
|
|
164
206
|
*
|
|
165
207
|
* @param {Engine} engine
|
|
@@ -223,4 +265,101 @@ export class FPDecalSystem extends AbstractContextSystem {
|
|
|
223
265
|
|
|
224
266
|
super.shutdown(em, ready_callback, error_callback);
|
|
225
267
|
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
*
|
|
271
|
+
* @param {number} origin_x
|
|
272
|
+
* @param {number} origin_y
|
|
273
|
+
* @param {number} origin_z
|
|
274
|
+
* @param {number} direction_x
|
|
275
|
+
* @param {number} direction_y
|
|
276
|
+
* @param {number} direction_z
|
|
277
|
+
* @param {function(entity:number, component:Decal):boolean} [filter_function]
|
|
278
|
+
* @param {*} [filter_function_context]
|
|
279
|
+
* @returns {{entity:number, component:Decal, contact: SurfacePoint3}[]}
|
|
280
|
+
*/
|
|
281
|
+
raycast(
|
|
282
|
+
origin_x, origin_y, origin_z,
|
|
283
|
+
direction_x, direction_y, direction_z,
|
|
284
|
+
filter_function = returnTrue, filter_function_context
|
|
285
|
+
) {
|
|
286
|
+
|
|
287
|
+
const ecd = this.entityManager.dataset;
|
|
288
|
+
|
|
289
|
+
if (ecd === null) {
|
|
290
|
+
return [];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const leaves = [];
|
|
294
|
+
|
|
295
|
+
const hit_count = bvh_query_leaves_ray(this.bvh, leaves, 0,
|
|
296
|
+
origin_x, origin_y, origin_z,
|
|
297
|
+
direction_x, direction_y, direction_z
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
const result = [];
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
for (let i = 0; i < hit_count; i++) {
|
|
304
|
+
const node = leaves[i];
|
|
305
|
+
|
|
306
|
+
const entity = this.bvh.node_get_user_data(node);
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
*
|
|
311
|
+
* @type {Decal}
|
|
312
|
+
*/
|
|
313
|
+
const decal = ecd.getComponent(entity, Decal);
|
|
314
|
+
|
|
315
|
+
if (decal === undefined) {
|
|
316
|
+
// this shouldn't happen
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
const transform = ecd.getComponent(entity, Transform);
|
|
322
|
+
|
|
323
|
+
if (transform === undefined) {
|
|
324
|
+
// this shouldn't happen either
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
ray3_array_compose(
|
|
329
|
+
scratch_ray_0,
|
|
330
|
+
origin_x, origin_y, origin_z,
|
|
331
|
+
direction_x, direction_y, direction_z
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
// get transform in local space
|
|
336
|
+
mat4.invert(scratch_m4, transform.matrix);
|
|
337
|
+
|
|
338
|
+
// transform ray into decal's local space
|
|
339
|
+
ray3_array_apply_matrix4(scratch_ray_0, 0, scratch_ray_0, 0, scratch_m4);
|
|
340
|
+
|
|
341
|
+
if (aabb3_intersects_ray(
|
|
342
|
+
-0.5, -0.5, -0.5,
|
|
343
|
+
0.5, 0.5, 0.5,
|
|
344
|
+
|
|
345
|
+
scratch_ray_0[0], scratch_ray_0[1], scratch_ray_0[2],
|
|
346
|
+
scratch_ray_0[3], scratch_ray_0[4], scratch_ray_0[5],
|
|
347
|
+
)) {
|
|
348
|
+
const contact = new SurfacePoint3();
|
|
349
|
+
|
|
350
|
+
// contact will be the center of decal, and normal will follow the decal normal
|
|
351
|
+
contact.applyMatrix4(transform.matrix);
|
|
352
|
+
|
|
353
|
+
result.push({
|
|
354
|
+
entity,
|
|
355
|
+
component: decal,
|
|
356
|
+
contact
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return result;
|
|
364
|
+
}
|
|
226
365
|
}
|
|
@@ -336,7 +336,7 @@ function makeNormalTestGridDecal(ecd, root_transform = new Transform()) {
|
|
|
336
336
|
side: DoubleSide
|
|
337
337
|
}), DrawMode.Triangles))
|
|
338
338
|
.add(arrow_transform)
|
|
339
|
-
|
|
339
|
+
.build(ecd);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
}
|
|
@@ -476,6 +476,26 @@ async function main(engine) {
|
|
|
476
476
|
//grid(engine.entityManager.dataset, 20,30,80, 25, .4, .6, .1, decal_urls.slice(105, 105+3));
|
|
477
477
|
// await promise_time_out(10);
|
|
478
478
|
|
|
479
|
+
engine.devices.pointer.position.onChanged.add(() => {
|
|
480
|
+
const ray_origin = new Vector3();
|
|
481
|
+
const ray_direction = new Vector3();
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
const pointer = engine.devices.pointer.position;
|
|
485
|
+
|
|
486
|
+
const ndc = new Vector2();
|
|
487
|
+
|
|
488
|
+
engine.graphics.normalizeViewportPoint(pointer,ndc);
|
|
489
|
+
engine.graphics.viewportProjectionRay(ndc.x, ndc.y, ray_origin, ray_direction);
|
|
490
|
+
|
|
491
|
+
const hits = engine.entityManager.getSystem(FPDecalSystem)?.raycast(
|
|
492
|
+
ray_origin.x, ray_origin.y, ray_origin.z,
|
|
493
|
+
ray_direction.x, ray_direction.y, ray_direction.z
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
console.warn(hits);
|
|
497
|
+
|
|
498
|
+
});
|
|
479
499
|
|
|
480
500
|
}
|
|
481
501
|
|
|
@@ -50,9 +50,6 @@ import {
|
|
|
50
50
|
bvh_query_user_data_overlaps_frustum
|
|
51
51
|
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
52
52
|
import { point_light_inside_volume } from "./query/point_light_inside_volume.js";
|
|
53
|
-
import { bvh_query_leaves_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
|
|
54
|
-
import { ray3_array_apply_matrix4 } from "../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
|
|
55
|
-
import { aabb3_intersects_ray } from "../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
|
|
56
53
|
|
|
57
54
|
|
|
58
55
|
/**
|
|
@@ -1205,61 +1202,4 @@ export class LightManager {
|
|
|
1205
1202
|
|
|
1206
1203
|
return true;
|
|
1207
1204
|
}
|
|
1208
|
-
|
|
1209
|
-
/**
|
|
1210
|
-
*
|
|
1211
|
-
* @param {Decal[]} result
|
|
1212
|
-
* @param {number} result_offset
|
|
1213
|
-
* @param {number[]} query
|
|
1214
|
-
* @param {number} query_offset
|
|
1215
|
-
* @returns {number} number of elements added to the result
|
|
1216
|
-
*/
|
|
1217
|
-
query_decals_by_ray(result, result_offset, query, query_offset) {
|
|
1218
|
-
|
|
1219
|
-
const leaves = [];
|
|
1220
|
-
const local_ray = new Float32Array(6);
|
|
1221
|
-
|
|
1222
|
-
const hit_count = bvh_query_leaves_ray(this.#light_data_bvh, leaves, 0,
|
|
1223
|
-
query[query_offset], query[query_offset + 1], query[query_offset + 2],
|
|
1224
|
-
query[query_offset + 3], query[query_offset + 4], query[query_offset + 5]
|
|
1225
|
-
);
|
|
1226
|
-
|
|
1227
|
-
let result_count = 0;
|
|
1228
|
-
|
|
1229
|
-
for (let i = 0; i < hit_count; i++) {
|
|
1230
|
-
const node = leaves[i];
|
|
1231
|
-
const light_id = this.#light_data_bvh.node_get_user_data(node);
|
|
1232
|
-
|
|
1233
|
-
const metadata = this.#metadata_map.get(light_id);
|
|
1234
|
-
|
|
1235
|
-
/**
|
|
1236
|
-
*
|
|
1237
|
-
* @type {Decal}
|
|
1238
|
-
*/
|
|
1239
|
-
const prop = metadata.light;
|
|
1240
|
-
|
|
1241
|
-
if (prop.isDecal !== true) {
|
|
1242
|
-
// wrong prop type
|
|
1243
|
-
continue;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
// transform ray into decal's local space
|
|
1247
|
-
ray3_array_apply_matrix4(local_ray, 0, query, query_offset, prop.transform_inverse);
|
|
1248
|
-
|
|
1249
|
-
if (aabb3_intersects_ray(
|
|
1250
|
-
-0.5, -0.5, -0.5,
|
|
1251
|
-
0.5, 0.5, 0.5,
|
|
1252
|
-
|
|
1253
|
-
local_ray[0], local_ray[1], local_ray[2],
|
|
1254
|
-
local_ray[3], local_ray[4], local_ray[5],
|
|
1255
|
-
)) {
|
|
1256
|
-
result[result_offset + result_count] = prop;
|
|
1257
|
-
|
|
1258
|
-
result_count++;
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
return result_count;
|
|
1264
|
-
}
|
|
1265
1205
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import {EnginePlugin} from "../../../../plugin/EnginePlugin";
|
|
2
|
-
import {Decal} from "../../../ecs/decal/v2/Decal";
|
|
3
2
|
|
|
4
3
|
export class ForwardPlusRenderingPlugin extends EnginePlugin {
|
|
5
4
|
setClusterResolution(x: number, y: number, z: number): void
|
|
6
|
-
|
|
7
|
-
queryDecalsByRay(result: Decal[], result_offset: number, query: ArrayLike<number>, query_offset?: number): number
|
|
8
5
|
}
|
|
@@ -89,15 +89,4 @@ export class ForwardPlusRenderingPlugin extends EnginePlugin {
|
|
|
89
89
|
return this.__light_manager;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @param {Decal[]} result
|
|
95
|
-
* @param {number} result_offset
|
|
96
|
-
* @param {number[]} query
|
|
97
|
-
* @param {number} query_offset
|
|
98
|
-
* @returns {number} number of elements added to the result
|
|
99
|
-
*/
|
|
100
|
-
queryDecalsByRay(result, result_offset, query, query_offset=0){
|
|
101
|
-
return this.__light_manager.query_decals_by_ray(result,result_offset, query,query_offset);
|
|
102
|
-
}
|
|
103
92
|
}
|