@woosh/meep-engine 2.59.0 → 2.59.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/meep.cjs +710 -644
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +710 -644
- package/editor/process/symbolic/SymbolicDisplayInternalAPI.js +3 -3
- package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makePathSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.js +1 -1
- package/editor/tools/TopDownCameraControlTool.js +2 -2
- package/editor/tools/v2/TransformControls.js +1 -1
- package/editor/tools/v2/prototypeTransformControls.js +1 -1
- package/package.json +1 -1
- package/samples/generation/main.js +1 -1
- package/samples/terrain/editor.js +1 -1
- package/src/core/collection/array/arraySetDiff.js +11 -7
- package/src/core/geom/3d/aabb/aabb3_array_intersects_point.spec.js +48 -0
- package/src/core/geom/3d/aabb/aabb3_array_intersects_ray.js +5 -1
- package/src/core/geom/3d/aabb/aabb3_expand_array.spec.js +16 -0
- package/src/core/geom/3d/aabb/aabb3_raycast.spec.js +37 -0
- package/src/core/geom/3d/aabb/aabb3_score_boxes_SAH.js +11 -12
- package/src/core/geom/3d/aabb/aabb3_score_boxes_SAH.spec.js +14 -0
- package/src/core/geom/3d/aabb/aabb3_transformed_compute_plane_side.js +6 -4
- package/src/core/geom/3d/aabb/compute_aabb_from_points.js +6 -3
- package/src/core/geom/3d/matrix/m4_multiply.spec.js +24 -0
- package/src/core/geom/3d/matrix/m4_multiply_alphatensor.js +56 -40
- package/src/core/geom/3d/matrix/m4_multiply_alphatensor.spec.js +24 -0
- package/src/core/geom/3d/shape/util/shape_to_visual_entity.js +2 -2
- package/src/core/geom/Vector3.spec.js +24 -14
- package/src/engine/EngineHarness.js +1 -1
- package/src/engine/control/ControlContext.js +1 -1
- package/src/engine/ecs/Entity.d.ts +2 -0
- package/src/engine/ecs/Entity.js +40 -37
- package/src/engine/ecs/Entity.spec.js +2 -2
- package/src/engine/ecs/EntityBuilderUtils.js +2 -2
- package/src/engine/ecs/EntityComponentDataset.js +91 -89
- package/src/engine/ecs/EntityFlags.js +4 -4
- package/src/engine/ecs/attachment/Attachment.js +5 -2
- package/src/engine/ecs/binding/ComponentPropertyBinding.js +13 -13
- package/src/engine/ecs/dynamic_actions/RuleExecution.js +1 -1
- package/src/engine/ecs/parent/EntityNode.js +2 -2
- package/src/engine/ecs/parent/EntityNode.spec.js +2 -2
- package/src/engine/ecs/tooltip/testTooltipComponentSystem.js +1 -1
- package/src/engine/ecs/util/hideEntityGracefully.js +6 -6
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +1 -0
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts +3 -0
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +69 -28
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +21 -15
- package/src/engine/graphics/ecs/mesh-v2/render/SGThreeObjectCache.js +30 -7
- package/src/engine/graphics/ecs/mesh-v2/sample/load_gltf.js +1 -1
- package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +71 -34
- package/src/engine/graphics/ecs/mesh-v2/sample/prototype_sg_raycast.js +1 -1
- package/src/engine/graphics/ecs/path/PathDisplaySystem.js +4 -4
- package/src/engine/graphics/ecs/path/entity/EntityPathMarker.js +1 -1
- package/src/engine/graphics/ecs/path/highlight/PathDisplayHighlightSystem.js +3 -3
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +5 -5
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -2
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +2 -2
- package/src/engine/intelligence/behavior/ecs/EntityBehavior.js +14 -17
- package/src/engine/intelligence/behavior/util/DelayBehavior.js +6 -6
- package/src/engine/ui/GUIEngine.js +368 -371
- package/src/engine/ui/notification/NotificationManager.js +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessor.js +1 -1
- package/src/view/tooltip/gml/TooltipParser.js +21 -28
- package/src/view/tooltip/gml/compiler/GMLReferenceCompiler.js +3 -2
- package/src/core/geom/3d/aabb/aabb3_intersects_ray_branchless.js +0 -52
- package/src/core/geom/3d/aabb/aabb3_intersects_ray_fast.js +0 -176
- package/src/core/geom/3d/aabb/aabb3_intersects_ray_slab.js +0 -91
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {resolvePath} from "../../../core/json/resolvePath.js";
|
|
2
2
|
|
|
3
3
|
export class ComponentPropertyBinding {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {ComponentPropertyPath}
|
|
7
|
+
*/
|
|
8
|
+
path = null;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @type {Vector1|Vector2|Vector3|ObservedBoolean}
|
|
13
|
+
*/
|
|
14
|
+
value = null;
|
|
15
|
+
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @template T
|
|
@@ -236,7 +236,7 @@ export class EntityNode {
|
|
|
236
236
|
throw new Error('Parent entity is not built');
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
const parent_entity_id = parent_entity_builder.
|
|
239
|
+
const parent_entity_id = parent_entity_builder.id;
|
|
240
240
|
parent_entity.entity = parent_entity_id;
|
|
241
241
|
|
|
242
242
|
// add component back
|
|
@@ -361,7 +361,7 @@ export class EntityNode {
|
|
|
361
361
|
throw new Error('Parent entity is not built');
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
const parent_entity_id = parent_entity_builder.
|
|
364
|
+
const parent_entity_id = parent_entity_builder.id;
|
|
365
365
|
parent_entity.entity = parent_entity_id;
|
|
366
366
|
|
|
367
367
|
assert.ok(parent.entity.hasComponent(Transform), "parent node must have a transform but doesn't. Transform is required for attachment transform hierarchy to work correctly");
|
|
@@ -83,7 +83,7 @@ test("build empty", () => {
|
|
|
83
83
|
|
|
84
84
|
expect(node.isBuilt).toBe(true);
|
|
85
85
|
expect(node.entity.isBuilt).toBe(true);
|
|
86
|
-
expect(dataset.entityExists(node.entity.
|
|
86
|
+
expect(dataset.entityExists(node.entity.id)).toBe(true);
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
test("destroy empty", () => {
|
|
@@ -93,7 +93,7 @@ test("destroy empty", () => {
|
|
|
93
93
|
|
|
94
94
|
node.build(dataset);
|
|
95
95
|
|
|
96
|
-
const entity = node.entity.
|
|
96
|
+
const entity = node.entity.id;
|
|
97
97
|
|
|
98
98
|
node.destroy();
|
|
99
99
|
|
|
@@ -83,7 +83,7 @@ function main(engine) {
|
|
|
83
83
|
pitch: -0.7
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
EngineHarness.buildOrbitalCameraController({ cameraEntity: camera.
|
|
86
|
+
EngineHarness.buildOrbitalCameraController({ cameraEntity: camera.id, engine });
|
|
87
87
|
|
|
88
88
|
const ecd = engine.entityManager.dataset;
|
|
89
89
|
|
|
@@ -25,14 +25,14 @@ const SHUTDOWN_GRACE_PERIOD = 60;
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
*
|
|
28
|
-
* @type {Map<Class|function, function(T,entity?:
|
|
28
|
+
* @type {Map<Class|function, function(T,entity?:Entity,createEntity?:function,createEntityContext?:*):number>}
|
|
29
29
|
*/
|
|
30
30
|
const component_shutdown = new Map();
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* @template T
|
|
34
34
|
* @param {Class<T>} type
|
|
35
|
-
* @param {function(T,entity?:
|
|
35
|
+
* @param {function(T,entity?:Entity,createEntity?:function,createEntityContext?:*):number} method
|
|
36
36
|
*/
|
|
37
37
|
function addShutdown(type, method) {
|
|
38
38
|
component_shutdown.set(type, method);
|
|
@@ -109,7 +109,7 @@ addShutdown(Light, (light, builder, createEntity, createEntityThisArg) => {
|
|
|
109
109
|
path: 'intensity',
|
|
110
110
|
target: [0],
|
|
111
111
|
duration: delay,
|
|
112
|
-
entity: builder.
|
|
112
|
+
entity: builder.id
|
|
113
113
|
}),
|
|
114
114
|
DieBehavior.create()
|
|
115
115
|
])));
|
|
@@ -161,8 +161,8 @@ addShutdown(SoundEmitter, (soundEmitter, builder, createEntity, createEntityThis
|
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
*
|
|
164
|
-
* @param {
|
|
165
|
-
* @param {function():
|
|
164
|
+
* @param {Entity} builder
|
|
165
|
+
* @param {function():Entity} createEntity
|
|
166
166
|
* @param {*} [createEntityThisArg]
|
|
167
167
|
* @return {number} duration in seconds until the entity is completely hidden
|
|
168
168
|
*/
|
|
@@ -174,7 +174,7 @@ export function hideEntityGracefully(builder, createEntity, createEntityThisArg)
|
|
|
174
174
|
|
|
175
175
|
let delay = 0;
|
|
176
176
|
|
|
177
|
-
const components = builder.
|
|
177
|
+
const components = builder.components;
|
|
178
178
|
|
|
179
179
|
const component_count = components.length;
|
|
180
180
|
|
|
@@ -39,6 +39,7 @@ const scratch_ray_0 = new Float32Array(6);
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Represents a primitive 3d object, a combination of a material and geometry
|
|
42
|
+
* This is roughly equivalent to single draw call, note that his is not a hierarchical data structure, if you want that - you will need to combine multiple entities, each with a `ShadedGeometry` component
|
|
42
43
|
*/
|
|
43
44
|
export class ShadedGeometry {
|
|
44
45
|
constructor() {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {Material} from "three";
|
|
1
2
|
import {AABB3} from "../../../../../core/geom/3d/aabb/AABB3";
|
|
2
3
|
|
|
3
4
|
export class SGMesh {
|
|
@@ -6,6 +7,8 @@ export class SGMesh {
|
|
|
6
7
|
castShadow: boolean
|
|
7
8
|
receiveShadow: boolean
|
|
8
9
|
|
|
10
|
+
materialOverride: Material
|
|
11
|
+
|
|
9
12
|
getBoundingBox(out: AABB3): boolean
|
|
10
13
|
|
|
11
14
|
getUntransformedBoundingBox(out: AABB3): void
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {AABB3} from "../../../../../core/geom/3d/aabb/AABB3.js";
|
|
2
|
+
import {entity_node_compute_bounding_box} from "../../../../ecs/parent/entity_node_compute_bounding_box.js";
|
|
3
|
+
import {ShadedGeometry} from "../ShadedGeometry.js";
|
|
3
4
|
|
|
4
5
|
export const SGMeshFlags = {
|
|
5
6
|
CastShadow: 1,
|
|
@@ -16,32 +17,72 @@ const DEFAULT_FLAGS = SGMeshFlags.CastShadow
|
|
|
16
17
|
;
|
|
17
18
|
|
|
18
19
|
export class SGMesh {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Allows settings a new material to all parts of the mesh
|
|
22
|
+
* @type {Material|null}
|
|
23
|
+
*/
|
|
24
|
+
#material_override = null;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @type {number}
|
|
29
|
+
*/
|
|
30
|
+
flags = DEFAULT_FLAGS;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @type {string|null}
|
|
35
|
+
*/
|
|
36
|
+
__url = null;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @type {EntityNode|null}
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
__node = null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @type {AABB3}
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
__initial_bounds = new AABB3();
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param {Material} v
|
|
55
|
+
*/
|
|
56
|
+
set materialOverride(v) {
|
|
57
|
+
if (v === this.#material_override) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (v === null) {
|
|
62
|
+
throw new Error(`Once material override is set it can not be cleared, create a new SGMesh instance if you would like to clear override`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.#material_override = v;
|
|
66
|
+
|
|
67
|
+
this.applyMaterialOverride();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get materialOverride() {
|
|
71
|
+
return this.#material_override;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
applyMaterialOverride() {
|
|
75
|
+
if (this.__node === null) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
this.__node.traverse(node => {
|
|
80
|
+
const sg = node.entity.getComponent(ShadedGeometry);
|
|
81
|
+
|
|
82
|
+
if (sg !== null) {
|
|
83
|
+
sg.material = this.#material_override;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
45
86
|
}
|
|
46
87
|
|
|
47
88
|
/**
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
1
|
+
import {min2} from "../../../../../core/math/min2.js";
|
|
2
|
+
import {ResourceAccessKind} from "../../../../../core/model/ResourceAccessKind.js";
|
|
3
|
+
import {ResourceAccessSpecification} from "../../../../../core/model/ResourceAccessSpecification.js";
|
|
4
|
+
import {EntityNode} from "../../../../ecs/parent/EntityNode.js";
|
|
5
|
+
import {ParentEntity} from "../../../../ecs/parent/ParentEntity.js";
|
|
6
|
+
import {System} from "../../../../ecs/System.js";
|
|
7
|
+
import {TransformAttachment} from "../../../../ecs/transform-attachment/TransformAttachment.js";
|
|
8
|
+
import {TransformAttachmentSystem} from "../../../../ecs/transform-attachment/TransformAttachmentSystem.js";
|
|
9
|
+
import {Transform} from "../../../../ecs/transform/Transform.js";
|
|
10
|
+
import {assetTypeByPath} from "../../mesh/assetTypeByPath.js";
|
|
11
|
+
import {ShadedGeometry} from "../ShadedGeometry.js";
|
|
12
|
+
import {ShadedGeometryFlags} from "../ShadedGeometryFlags.js";
|
|
13
|
+
import {three_object_to_entity_composition} from "../three_object_to_entity_composition.js";
|
|
14
|
+
import {SGMesh} from "./SGMesh.js";
|
|
15
|
+
import {SGMeshEvents} from "./SGMeshEvents.js";
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -179,6 +179,8 @@ export class SGMeshSystem extends System {
|
|
|
179
179
|
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
+
const material_override = mesh.materialOverride;
|
|
183
|
+
|
|
182
184
|
// apply flags to the hierarchy
|
|
183
185
|
entity_node.traverse(node => {
|
|
184
186
|
/**
|
|
@@ -192,6 +194,10 @@ export class SGMeshSystem extends System {
|
|
|
192
194
|
|
|
193
195
|
sg.writeFlag(ShadedGeometryFlags.CastShadow, mesh.castShadow);
|
|
194
196
|
sg.writeFlag(ShadedGeometryFlags.ReceiveShadow, mesh.receiveShadow);
|
|
197
|
+
|
|
198
|
+
if (material_override !== null) {
|
|
199
|
+
sg.material = material_override;
|
|
200
|
+
}
|
|
195
201
|
});
|
|
196
202
|
|
|
197
203
|
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {build_three_object} from "../build_three_object.js";
|
|
2
|
+
import {ShadedGeometry} from "../ShadedGeometry.js";
|
|
3
|
+
|
|
4
|
+
class CacheValue {
|
|
5
|
+
object = null
|
|
6
|
+
key = null
|
|
7
|
+
}
|
|
8
|
+
|
|
2
9
|
|
|
3
10
|
export class SGThreeObjectCache {
|
|
4
11
|
constructor() {
|
|
5
12
|
/**
|
|
6
13
|
*
|
|
7
|
-
* @type {
|
|
14
|
+
* @type {Map<ShadedGeometry, CacheValue>}
|
|
8
15
|
* @private
|
|
9
16
|
*/
|
|
10
17
|
this.__object_cache = new WeakMap();
|
|
@@ -17,15 +24,31 @@ export class SGThreeObjectCache {
|
|
|
17
24
|
*/
|
|
18
25
|
get(sg) {
|
|
19
26
|
|
|
20
|
-
const
|
|
27
|
+
const existing_value = this.__object_cache.get(sg);
|
|
28
|
+
|
|
29
|
+
if (existing_value !== undefined) {
|
|
30
|
+
const object = existing_value.object;
|
|
21
31
|
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
// validate that the object is still the same
|
|
33
|
+
if (existing_value.key.equals(sg)) {
|
|
34
|
+
return object;
|
|
35
|
+
} else {
|
|
36
|
+
// object has changed, dispose of cached version and let it be rebuilt
|
|
37
|
+
// object.dispose();
|
|
38
|
+
}
|
|
24
39
|
}
|
|
25
40
|
|
|
26
|
-
|
|
41
|
+
// replace scratch key as it's being used inside the cache now
|
|
42
|
+
const key = sg.clone();
|
|
43
|
+
|
|
44
|
+
const new_object = build_three_object(key);
|
|
45
|
+
|
|
46
|
+
const cacheValue = new CacheValue();
|
|
47
|
+
|
|
48
|
+
cacheValue.key = key;
|
|
49
|
+
cacheValue.object = new_object;
|
|
27
50
|
|
|
28
|
-
this.__object_cache.set(sg,
|
|
51
|
+
this.__object_cache.set(sg, cacheValue);
|
|
29
52
|
|
|
30
53
|
return new_object;
|
|
31
54
|
}
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {BoxBufferGeometry, MeshStandardMaterial, OctahedronGeometry} from "three";
|
|
2
|
+
import {OrbitingBehavior} from "../../../../../../../model/game/util/behavior/OrbitingBehavior.js";
|
|
3
|
+
import {downloadAsFile} from "../../../../../core/binary/downloadAsFile.js";
|
|
4
|
+
import {convert_bvh_to_dot_format_string} from "../../../../../core/bvh2/visual/convert_bvh_to_dot_format_string.js";
|
|
5
|
+
import {Color} from "../../../../../core/color/Color.js";
|
|
6
|
+
import Quaternion from "../../../../../core/geom/Quaternion.js";
|
|
7
|
+
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
8
|
+
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
9
|
+
import {randomFloatBetween} from "../../../../../core/math/random/randomFloatBetween.js";
|
|
10
|
+
import {randomFromArray} from "../../../../../core/math/random/randomFromArray.js";
|
|
11
|
+
import {seededRandom} from "../../../../../core/math/random/seededRandom.js";
|
|
12
|
+
import ButtonView from "../../../../../view/elements/button/ButtonView.js";
|
|
3
13
|
import Entity from "../../../../ecs/Entity.js";
|
|
4
|
-
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
5
|
-
import { ShadedGeometry } from "../ShadedGeometry.js";
|
|
6
|
-
import { BoxBufferGeometry, MeshStandardMaterial, OctahedronGeometry } from "three";
|
|
7
|
-
import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
|
|
8
|
-
import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
|
|
9
|
-
import ViewportPosition from "../../../../ecs/gui/position/ViewportPosition.js";
|
|
10
14
|
import GUIElement from "../../../../ecs/gui/GUIElement.js";
|
|
11
|
-
import ButtonView from "../../../../../view/elements/button/ButtonView.js";
|
|
12
|
-
import { convert_bvh_to_dot_format_string } from "../../../../../core/bvh2/visual/convert_bvh_to_dot_format_string.js";
|
|
13
|
-
import ViewportPositionSystem from "../../../../ecs/gui/position/ViewportPositionSystem.js";
|
|
14
15
|
import GUIElementSystem from "../../../../ecs/gui/GUIElementSystem.js";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
16
|
+
import ViewportPosition from "../../../../ecs/gui/position/ViewportPosition.js";
|
|
17
|
+
import ViewportPositionSystem from "../../../../ecs/gui/position/ViewportPositionSystem.js";
|
|
18
|
+
import {Transform} from "../../../../ecs/transform/Transform.js";
|
|
19
|
+
import {EngineHarness} from "../../../../EngineHarness.js";
|
|
20
|
+
import {SequenceBehavior} from "../../../../intelligence/behavior/composite/SequenceBehavior.js";
|
|
21
|
+
import {RepeatBehavior} from "../../../../intelligence/behavior/decorator/RepeatBehavior.js";
|
|
22
|
+
import {BehaviorComponent} from "../../../../intelligence/behavior/ecs/BehaviorComponent.js";
|
|
23
|
+
import {BehaviorSystem} from "../../../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
24
|
+
import {ActionBehavior} from "../../../../intelligence/behavior/primitive/ActionBehavior.js";
|
|
25
|
+
import {DelayBehavior} from "../../../../intelligence/behavior/util/DelayBehavior.js";
|
|
26
|
+
import {ShadedGeometry} from "../ShadedGeometry.js";
|
|
27
|
+
import {ShadedGeometryFlags} from "../ShadedGeometryFlags.js";
|
|
28
|
+
import {ShadedGeometrySystem} from "../ShadedGeometrySystem.js";
|
|
24
29
|
|
|
25
30
|
const eh = new EngineHarness();
|
|
26
31
|
|
|
@@ -33,7 +38,7 @@ function makeMovingShadedGeometry() {
|
|
|
33
38
|
b.radius = 2;
|
|
34
39
|
b.rate = 1;
|
|
35
40
|
|
|
36
|
-
const sg = ShadedGeometry.from(new OctahedronGeometry(0.5, 5), new MeshStandardMaterial({
|
|
41
|
+
const sg = ShadedGeometry.from(new OctahedronGeometry(0.5, 5), new MeshStandardMaterial({color: 0xFF0000}));
|
|
37
42
|
|
|
38
43
|
sg.draw_method = DRAW_METHOD_INSTANCED;
|
|
39
44
|
|
|
@@ -89,31 +94,60 @@ async function main(engine) {
|
|
|
89
94
|
geometries.push(new BoxBufferGeometry());
|
|
90
95
|
}
|
|
91
96
|
|
|
97
|
+
const entities = [];
|
|
98
|
+
|
|
92
99
|
for (let i = 0; i < INSTANCE_COUNT; i++) {
|
|
93
100
|
const geometry = randomFromArray(random, geometries);
|
|
94
101
|
const sg = ShadedGeometry.from(geometry, material);
|
|
95
102
|
|
|
96
|
-
|
|
97
|
-
sg.
|
|
103
|
+
sg.draw_method = DRAW_METHOD_PLAIN;
|
|
104
|
+
sg.setFlag(ShadedGeometryFlags.DrawMethodLocked);
|
|
105
|
+
// sg.draw_method = DRAW_METHOD_INSTANCED;
|
|
98
106
|
// sg.draw_method = 2;
|
|
99
107
|
// sg.draw_method = DRAW_METHOD_INSTANCED;
|
|
100
108
|
// sg.draw_method = random() > 0.5 ? DRAW_METHOD_INSTANCED : 2;
|
|
101
109
|
sg.clearFlag(ShadedGeometryFlags.CastShadow | ShadedGeometryFlags.ReceiveShadow);
|
|
102
110
|
|
|
103
|
-
new Entity()
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
const entity = new Entity();
|
|
112
|
+
|
|
113
|
+
entity.add(Transform.fromJSON({
|
|
114
|
+
position: {
|
|
115
|
+
x: randomFloatBetween(random, 0, TERRAIN_SIZE),
|
|
116
|
+
y: randomFloatBetween(random, 0, 10),
|
|
117
|
+
z: randomFloatBetween(random, 0, TERRAIN_SIZE)
|
|
118
|
+
},
|
|
119
|
+
rotation: Quaternion.random(random),
|
|
120
|
+
scale: 0.1
|
|
121
|
+
}))
|
|
113
122
|
.add(sg)
|
|
114
123
|
.build(ecd);
|
|
124
|
+
|
|
125
|
+
entities.push(entity);
|
|
115
126
|
}
|
|
116
127
|
|
|
128
|
+
let iterator = 0;
|
|
129
|
+
|
|
130
|
+
new Entity()
|
|
131
|
+
.add(BehaviorComponent.fromOne(
|
|
132
|
+
RepeatBehavior.from(SequenceBehavior.from([
|
|
133
|
+
DelayBehavior.from(0.001),
|
|
134
|
+
RepeatBehavior.from(new ActionBehavior(() => {
|
|
135
|
+
const index = (iterator++) % entities.length;
|
|
136
|
+
const entity = entities[index];
|
|
137
|
+
|
|
138
|
+
const sg = entity.getComponent(ShadedGeometry);
|
|
139
|
+
|
|
140
|
+
const color = new Color();
|
|
141
|
+
color.setHSV(random(), 0.7, 1);
|
|
142
|
+
|
|
143
|
+
sg.material = new MeshStandardMaterial({
|
|
144
|
+
color: color.toUint()
|
|
145
|
+
});
|
|
146
|
+
}), 1000)
|
|
147
|
+
]))
|
|
148
|
+
))
|
|
149
|
+
.build(ecd);
|
|
150
|
+
|
|
117
151
|
// makeMovingShadedGeometry().build(ecd);
|
|
118
152
|
|
|
119
153
|
debug_button(engine, () => {
|
|
@@ -158,4 +192,7 @@ function debug_button(engine, action, name = "Button", ecd = entityManager.datas
|
|
|
158
192
|
.build(ecd);
|
|
159
193
|
}
|
|
160
194
|
|
|
161
|
-
eh.initialize(
|
|
195
|
+
eh.initialize({
|
|
196
|
+
configuration(config, engine) {
|
|
197
|
+
}
|
|
198
|
+
}).then(main);
|
|
@@ -168,7 +168,7 @@ async function main(engine) {
|
|
|
168
168
|
const sp = new SurfacePoint3();
|
|
169
169
|
|
|
170
170
|
sgm.raycastNearest(sp, ray_origin.x, ray_origin.y, ray_origin.z, ray_direction.x, ray_direction.y, ray_direction.z, ((entity, mesh) => {
|
|
171
|
-
return (entity !== raycast_marker.
|
|
171
|
+
return (entity !== raycast_marker.id);
|
|
172
172
|
}));
|
|
173
173
|
|
|
174
174
|
const t = raycast_marker.getComponent(Transform);
|
|
@@ -27,7 +27,7 @@ const builders = {
|
|
|
27
27
|
* @param {EntityPathStyle} style
|
|
28
28
|
* @param {Path} _p
|
|
29
29
|
* @param {PathDisplaySystem} system
|
|
30
|
-
* @param {
|
|
30
|
+
* @param {Entity[]} result
|
|
31
31
|
*/
|
|
32
32
|
[PathDisplayType.Entity]: function (style, path, system, result) {
|
|
33
33
|
|
|
@@ -54,7 +54,7 @@ const builders = {
|
|
|
54
54
|
* @param {RibbonPathStyle} style
|
|
55
55
|
* @param {Path} path
|
|
56
56
|
* @param {PathDisplaySystem} system
|
|
57
|
-
* @param {
|
|
57
|
+
* @param {Entity[]} result
|
|
58
58
|
*/
|
|
59
59
|
[PathDisplayType.Ribbon]: function (style, path, system, result) {
|
|
60
60
|
const builder = new RibbonPathBuilder();
|
|
@@ -72,7 +72,7 @@ const builders = {
|
|
|
72
72
|
* @param {TubePathStyle} style
|
|
73
73
|
* @param {Path} path
|
|
74
74
|
* @param {PathDisplaySystem} system
|
|
75
|
-
* @param {
|
|
75
|
+
* @param {Entity[]} result
|
|
76
76
|
*/
|
|
77
77
|
[PathDisplayType.Tube]: function (style, path, system, result) {
|
|
78
78
|
const builder = new TubePathBuilder();
|
|
@@ -103,7 +103,7 @@ class PathDisplayContext extends SystemEntityContext {
|
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
*
|
|
106
|
-
* @type {
|
|
106
|
+
* @type {Entity[]}
|
|
107
107
|
* @private
|
|
108
108
|
*/
|
|
109
109
|
this.__owned_entities = [];
|
|
@@ -63,7 +63,7 @@ export class PathDisplayHighlightSystem extends System {
|
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
*
|
|
66
|
-
* @type {
|
|
66
|
+
* @type {Entity[]}
|
|
67
67
|
*/
|
|
68
68
|
const ownedEntities = ctx.__owned_entities;
|
|
69
69
|
|
|
@@ -72,7 +72,7 @@ export class PathDisplayHighlightSystem extends System {
|
|
|
72
72
|
|
|
73
73
|
if (eb.hasComponent(Highlight)) {
|
|
74
74
|
//already has a highlight
|
|
75
|
-
console.warn(`Owned entity ${eb.
|
|
75
|
+
console.warn(`Owned entity ${eb.id} of PathDisplay entity ${entity} already has a Highlight component attached. Keeping existing Highlight.`);
|
|
76
76
|
continue;
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -105,7 +105,7 @@ export class PathDisplayHighlightSystem extends System {
|
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
*
|
|
108
|
-
* @type {
|
|
108
|
+
* @type {Entity[]}
|
|
109
109
|
*/
|
|
110
110
|
const ownedEntities = ctx.__owned_entities;
|
|
111
111
|
|
|
@@ -270,7 +270,7 @@ function main(engine) {
|
|
|
270
270
|
|
|
271
271
|
const ecd = engine.entityManager.dataset;
|
|
272
272
|
|
|
273
|
-
// new
|
|
273
|
+
// new Entity()
|
|
274
274
|
// .add(Transform.fromJSON({
|
|
275
275
|
// position: {
|
|
276
276
|
// x: 100,
|
|
@@ -290,7 +290,7 @@ function main(engine) {
|
|
|
290
290
|
// }))
|
|
291
291
|
// .build(ecd);
|
|
292
292
|
|
|
293
|
-
// new
|
|
293
|
+
// new Entity()
|
|
294
294
|
// .add(Transform.fromJSON({
|
|
295
295
|
// position: {
|
|
296
296
|
// x: 107,
|
|
@@ -335,7 +335,7 @@ function main(engine) {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
//
|
|
338
|
-
// new
|
|
338
|
+
// new Entity()
|
|
339
339
|
// .add(Transform.fromJSON({
|
|
340
340
|
// position: {
|
|
341
341
|
// x: 107,
|
|
@@ -355,7 +355,7 @@ function main(engine) {
|
|
|
355
355
|
// }))
|
|
356
356
|
// .build(ecd);
|
|
357
357
|
|
|
358
|
-
// new
|
|
358
|
+
// new Entity()
|
|
359
359
|
// .add(Transform.fromJSON({
|
|
360
360
|
// position: {
|
|
361
361
|
// x: 107,
|
|
@@ -377,7 +377,7 @@ function main(engine) {
|
|
|
377
377
|
|
|
378
378
|
// const canvasView = makeCameraClippingDebug(engine);
|
|
379
379
|
//
|
|
380
|
-
// new
|
|
380
|
+
// new Entity()
|
|
381
381
|
// .add(ViewportPosition.fromJSON({
|
|
382
382
|
// offset: new Vector2(10, 10)
|
|
383
383
|
// }))
|