@woosh/meep-engine 2.46.29 → 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
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BufferGeometry, Float32BufferAttribute, Group, Line, LineBasicMaterial } from "three";
|
|
2
|
+
import Vector3 from "../../../src/core/geom/Vector3.js";
|
|
3
|
+
import { min2 } from "../../../src/core/math/min2.js";
|
|
4
|
+
import Renderable from "../../../src/engine/ecs/components/Renderable.js";
|
|
5
|
+
import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
|
|
6
|
+
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
7
|
+
import Path from "../../../src/engine/navigation/ecs/components/Path.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @return {ComponentSymbolicDisplay}
|
|
12
|
+
* @param {Engine} engine
|
|
13
|
+
*/
|
|
14
|
+
export function makePathSymbolicDisplay(engine) {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {Path} path
|
|
19
|
+
* @param {number} q
|
|
20
|
+
* @returns {BufferGeometry}
|
|
21
|
+
*/
|
|
22
|
+
function buildPathGeometry(path, q) {
|
|
23
|
+
const geometry = new BufferGeometry();
|
|
24
|
+
|
|
25
|
+
const vertices = [];
|
|
26
|
+
|
|
27
|
+
const v3 = new Vector3();
|
|
28
|
+
|
|
29
|
+
const length = path.computeLength();
|
|
30
|
+
const minStep = (length / path.getPointCount()) / 10;
|
|
31
|
+
const step = min2(q, minStep);
|
|
32
|
+
|
|
33
|
+
const p = path;
|
|
34
|
+
|
|
35
|
+
let i = 0;
|
|
36
|
+
|
|
37
|
+
for (let c = 0; c < length; c += step) {
|
|
38
|
+
p.sample(v3, c);
|
|
39
|
+
|
|
40
|
+
vertices[i++] = v3.x;
|
|
41
|
+
vertices[i++] = v3.y;
|
|
42
|
+
vertices[i++] = v3.z;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
geometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));
|
|
46
|
+
|
|
47
|
+
return geometry;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {Path} path
|
|
53
|
+
* @param entity
|
|
54
|
+
* @param {SymbolicDisplayInternalAPI} api
|
|
55
|
+
* @return {EntityBuilder}
|
|
56
|
+
*/
|
|
57
|
+
function factory([path, entity], api) {
|
|
58
|
+
const pathObjectMaterial = new LineBasicMaterial({ color: 0xFF0000, opacity: 0.4 });
|
|
59
|
+
pathObjectMaterial.depthTest = false;
|
|
60
|
+
|
|
61
|
+
const q = 0.01;
|
|
62
|
+
|
|
63
|
+
const pathObject = new Line(buildPathGeometry(path, q), pathObjectMaterial);
|
|
64
|
+
pathObject.castShadow = true;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
function update() {
|
|
68
|
+
pathObject.geometry = buildPathGeometry(path, q);
|
|
69
|
+
|
|
70
|
+
b.getComponent(Renderable).computeBoundsFromObject();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (let i = 0; i < path.getPointCount(); i++) {
|
|
74
|
+
const p = new Vector3();
|
|
75
|
+
|
|
76
|
+
path.getPosition(i, p);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
api.bind(p.onChanged, () => {
|
|
80
|
+
update();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
const group = new Group();
|
|
87
|
+
group.frustumCulled = false;
|
|
88
|
+
|
|
89
|
+
group.add(pathObject);
|
|
90
|
+
|
|
91
|
+
const b = buildThreeJSHelperEntity(group);
|
|
92
|
+
|
|
93
|
+
const r = b.getComponent(Renderable);
|
|
94
|
+
|
|
95
|
+
r.matrixAutoUpdate = false;
|
|
96
|
+
|
|
97
|
+
api.emit(b);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return make3DSymbolicDisplay({
|
|
101
|
+
engine,
|
|
102
|
+
components: [Path],
|
|
103
|
+
factory
|
|
104
|
+
})
|
|
105
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { assert } from "../../../src/core/assert.js";
|
|
2
|
+
import { Sprite, SpriteMaterial } from "three";
|
|
3
|
+
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
4
|
+
import EntityBuilder from "../../../src/engine/ecs/EntityBuilder.js";
|
|
5
|
+
import Renderable from "../../../src/engine/ecs/components/Renderable.js";
|
|
6
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
7
|
+
import { synchronizeTransform } from "./synchronizeTransform.js";
|
|
8
|
+
|
|
9
|
+
const SPRITE_SIZE = 0.3;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @template C,T
|
|
13
|
+
* @param {Engine} engine
|
|
14
|
+
* @param {string} iconURL
|
|
15
|
+
* @param {C} ComponentClass
|
|
16
|
+
* @returns {ComponentSymbolicDisplay}
|
|
17
|
+
*/
|
|
18
|
+
export function makePositionedIconDisplaySymbol(engine, iconURL, ComponentClass) {
|
|
19
|
+
assert.defined(engine, 'engine');
|
|
20
|
+
assert.ok(engine.isEngine, 'engine.isEngine');
|
|
21
|
+
|
|
22
|
+
const entityManager = engine.entityManager;
|
|
23
|
+
|
|
24
|
+
const assetManager = engine.assetManager;
|
|
25
|
+
|
|
26
|
+
const spriteMaterial = new SpriteMaterial();
|
|
27
|
+
spriteMaterial.depthTest = false;
|
|
28
|
+
spriteMaterial.transparent = true;
|
|
29
|
+
spriteMaterial.depthWrite = true;
|
|
30
|
+
|
|
31
|
+
assetManager.promise(iconURL, 'texture').then(asset => {
|
|
32
|
+
|
|
33
|
+
spriteMaterial.map = asset.create();
|
|
34
|
+
spriteMaterial.needsUpdate = true;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return make3DSymbolicDisplay({
|
|
38
|
+
engine,
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param component
|
|
42
|
+
* @param transform
|
|
43
|
+
* @param entity
|
|
44
|
+
* @param {SymbolicDisplayInternalAPI} api
|
|
45
|
+
* @return {EntityBuilder}
|
|
46
|
+
*/
|
|
47
|
+
factory([component, transform, entity], api) {
|
|
48
|
+
|
|
49
|
+
const b = new EntityBuilder();
|
|
50
|
+
|
|
51
|
+
const sprite = new Sprite(spriteMaterial);
|
|
52
|
+
sprite.frustumCulled = false;
|
|
53
|
+
sprite.matrixAutoUpdate = false;
|
|
54
|
+
//draw on top of everything else
|
|
55
|
+
sprite.renderOrder = 9999;
|
|
56
|
+
|
|
57
|
+
const cR = new Renderable(sprite);
|
|
58
|
+
const cT = new Transform();
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
//sprite size
|
|
62
|
+
cT.scale.set(SPRITE_SIZE, SPRITE_SIZE, SPRITE_SIZE);
|
|
63
|
+
cR.boundingBox.setBounds(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5);
|
|
64
|
+
|
|
65
|
+
synchronizeTransform(transform, cT, api.bindings, true, false, false);
|
|
66
|
+
|
|
67
|
+
b.add(cR);
|
|
68
|
+
b.add(cT);
|
|
69
|
+
|
|
70
|
+
api.emit(b);
|
|
71
|
+
},
|
|
72
|
+
components: [ComponentClass, Transform]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { AxesHelper, Group, Mesh as ThreeMesh, MeshBasicMaterial, SphereBufferGeometry } from "three";
|
|
2
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
3
|
+
import { Attachment } from "../../../src/engine/ecs/attachment/Attachment.js";
|
|
4
|
+
import { BoneAttachmentSocket } from "../../../src/engine/ecs/sockets/BoneAttachmentSocket.js";
|
|
5
|
+
import { BoneAttachmentBinding } from "../../../src/engine/ecs/attachment/BoneAttachmentBinding.js";
|
|
6
|
+
import Mesh from "../../../src/engine/graphics/ecs/mesh/Mesh.js";
|
|
7
|
+
import { TransformAttachmentBinding } from "../../../src/engine/ecs/attachment/TransformAttachmentBinding.js";
|
|
8
|
+
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
9
|
+
import { AttachmentSockets } from "../../../src/engine/ecs/sockets/AttachmentSockets.js";
|
|
10
|
+
import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
|
|
11
|
+
import ViewportPosition from "../../../src/engine/ecs/gui/position/ViewportPosition.js";
|
|
12
|
+
import LabelView from "../../../src/view/common/LabelView.js";
|
|
13
|
+
import HeadsUpDisplay from "../../../src/engine/ecs/gui/hud/HeadsUpDisplay.js";
|
|
14
|
+
import GUIElement from "../../../src/engine/ecs/gui/GUIElement.js";
|
|
15
|
+
import { MeshEvents } from "../../../src/engine/graphics/ecs/mesh/MeshEvents.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {Engine} engine
|
|
20
|
+
* @return {ComponentSymbolicDisplay}
|
|
21
|
+
*/
|
|
22
|
+
export function makeSocketsSymbolicDisplay(engine) {
|
|
23
|
+
|
|
24
|
+
const centerMaterial = new MeshBasicMaterial({
|
|
25
|
+
color: 0x00FFFF,
|
|
26
|
+
transparent: true,
|
|
27
|
+
opacity: 0.2
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const centerGeometry = new SphereBufferGeometry(0.05, 10, 10);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param {AttachmentSockets} sockets
|
|
35
|
+
* @param {Transform} transform
|
|
36
|
+
* @param {number} entity
|
|
37
|
+
* @param {SymbolicDisplayInternalAPI} api
|
|
38
|
+
*/
|
|
39
|
+
function factory([sockets, transform, entity], api) {
|
|
40
|
+
|
|
41
|
+
const ecd = engine.entityManager.dataset;
|
|
42
|
+
|
|
43
|
+
const rebuild = () => {
|
|
44
|
+
|
|
45
|
+
ecd.removeEntityEventListener(entity, MeshEvents.DataSet, rebuild);
|
|
46
|
+
|
|
47
|
+
api.update();
|
|
48
|
+
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
ecd.addEntityEventListener(entity, MeshEvents.DataSet, rebuild);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param {AttachmentSocket} socket
|
|
56
|
+
*/
|
|
57
|
+
function buildGizmo(socket) {
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @type {AttachmentBinding}
|
|
61
|
+
*/
|
|
62
|
+
let binding = null;
|
|
63
|
+
let t = new Transform();
|
|
64
|
+
|
|
65
|
+
const attachment = new Attachment();
|
|
66
|
+
|
|
67
|
+
if (socket instanceof BoneAttachmentSocket) {
|
|
68
|
+
binding = new BoneAttachmentBinding();
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @type {Mesh}
|
|
73
|
+
*/
|
|
74
|
+
const mesh = engine.entityManager.dataset.getComponent(entity, Mesh);
|
|
75
|
+
|
|
76
|
+
const bone = mesh.getDescendantObjectByName(socket.boneName);
|
|
77
|
+
|
|
78
|
+
binding.bone = bone;
|
|
79
|
+
} else {
|
|
80
|
+
binding = new TransformAttachmentBinding();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
binding.attachment = attachment;
|
|
84
|
+
|
|
85
|
+
binding.parentEntity = entity;
|
|
86
|
+
binding.parentTransform = transform;
|
|
87
|
+
binding.socket = socket;
|
|
88
|
+
|
|
89
|
+
binding.attachedTransform = t;
|
|
90
|
+
|
|
91
|
+
const socket_group = new Group();
|
|
92
|
+
socket_group.frustumCulled = false;
|
|
93
|
+
|
|
94
|
+
const helper = new AxesHelper(2 * transform.scale.x);
|
|
95
|
+
helper.frustumCulled = false;
|
|
96
|
+
|
|
97
|
+
const mesh = new ThreeMesh(centerGeometry, centerMaterial);
|
|
98
|
+
mesh.frustumCulled = false;
|
|
99
|
+
|
|
100
|
+
socket_group.add(mesh);
|
|
101
|
+
socket_group.add(helper);
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
const builder = buildThreeJSHelperEntity(socket_group, entity);
|
|
105
|
+
|
|
106
|
+
const v = new LabelView(socket.id, { classList: ['__debug-plaque'] });
|
|
107
|
+
v.css({
|
|
108
|
+
position: 'absolute',
|
|
109
|
+
whiteSpace: 'pre',
|
|
110
|
+
left: 0,
|
|
111
|
+
top: 0
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
builder.add(new HeadsUpDisplay())
|
|
115
|
+
.add(new ViewportPosition())
|
|
116
|
+
.add(GUIElement.fromView(v))
|
|
117
|
+
|
|
118
|
+
function update_transform() {
|
|
119
|
+
binding.update();
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @type {Transform}
|
|
124
|
+
*/
|
|
125
|
+
const transform = builder.getComponent(Transform);
|
|
126
|
+
|
|
127
|
+
transform.copy(t);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
api.onFrame(update_transform);
|
|
131
|
+
|
|
132
|
+
api.bind(sockets.elements.on.removed, (s) => {
|
|
133
|
+
if (s === socket) {
|
|
134
|
+
builder.destroy();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
api.emit(builder);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
sockets.elements.forEach(buildGizmo);
|
|
142
|
+
|
|
143
|
+
api.bind(sockets.elements.on.added, buildGizmo);
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return make3DSymbolicDisplay({
|
|
148
|
+
engine,
|
|
149
|
+
components: [AttachmentSockets, Transform],
|
|
150
|
+
factory
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|