@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
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import GuiControl from "../../../../../src/view/controller/controls/GuiControl.js";
|
|
2
|
+
import DatGuiController from "../DatGuiController.js";
|
|
3
|
+
import Vector3Control from "../../../../../src/view/controller/controls/Vector3Control.js";
|
|
4
|
+
import NumericIntervalControl from "../../../../../src/view/controller/controls/NumericIntervalControl.js";
|
|
5
|
+
import { enumNameByValue } from "./ParticleEmitterController.js";
|
|
6
|
+
import ListController from "../../../../../src/view/controller/controls/ListController.js";
|
|
7
|
+
import {
|
|
8
|
+
ParameterTrack
|
|
9
|
+
} from "../../../../../src/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js";
|
|
10
|
+
import { ParameterTrackController } from "./ParameterTrackController.js";
|
|
11
|
+
import {
|
|
12
|
+
ParticleParameters
|
|
13
|
+
} from "../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleParameters.js";
|
|
14
|
+
import {
|
|
15
|
+
ParameterLookupTable
|
|
16
|
+
} from "../../../../../src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js";
|
|
17
|
+
import {
|
|
18
|
+
EmissionFromType
|
|
19
|
+
} from "../../../../../src/engine/graphics/particles/particular/engine/emitter/EmissionFromType.js";
|
|
20
|
+
import {
|
|
21
|
+
EmissionShapeType
|
|
22
|
+
} from "../../../../../src/engine/graphics/particles/particular/engine/emitter/EmissionShapeType.js";
|
|
23
|
+
|
|
24
|
+
class ParticleLayerController extends GuiControl {
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {function(function)} mutationHook
|
|
28
|
+
*/
|
|
29
|
+
constructor(mutationHook) {
|
|
30
|
+
super();
|
|
31
|
+
|
|
32
|
+
const self = this;
|
|
33
|
+
|
|
34
|
+
const surrogate = {
|
|
35
|
+
imageURL: "",
|
|
36
|
+
emissionShape: EmissionShapeType.Point,
|
|
37
|
+
emissionFrom: EmissionFromType.Volume,
|
|
38
|
+
emissionRate: 0,
|
|
39
|
+
emissionImmediate: 0,
|
|
40
|
+
velocityAngle: 0
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @returns {ParticleLayer}
|
|
46
|
+
*/
|
|
47
|
+
function getLayer() {
|
|
48
|
+
return self.model.getValue();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @template T
|
|
53
|
+
* @param {function(ParticleLayer,T?)} f
|
|
54
|
+
* @param {T} [arg0]
|
|
55
|
+
*/
|
|
56
|
+
function mutate(f, arg0) {
|
|
57
|
+
mutationHook(() => {
|
|
58
|
+
f(getLayer(), arg0);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {function(ParticleLayer,*)} f
|
|
65
|
+
* @returns {function(...[*]=)}
|
|
66
|
+
*/
|
|
67
|
+
function mutator(f) {
|
|
68
|
+
return function (arg0) {
|
|
69
|
+
mutate(f, arg0);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param {string} property
|
|
76
|
+
* @param {function(layer:ParticleLayer, value:*)} mutationCallback
|
|
77
|
+
* @param {*} ops
|
|
78
|
+
*/
|
|
79
|
+
function addControl(property, mutationCallback, ops) {
|
|
80
|
+
const controller = dat.addControl(surrogate, property, ops);
|
|
81
|
+
|
|
82
|
+
controller.onChange(mutator(mutationCallback));
|
|
83
|
+
|
|
84
|
+
return controller;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const dat = new DatGuiController();
|
|
88
|
+
|
|
89
|
+
const cImageURL = addControl('imageURL', (layer, value) => {
|
|
90
|
+
layer.imageURL = value;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const cEmissionShape = addControl(
|
|
94
|
+
'emissionShape',
|
|
95
|
+
function (layer, shapeTypeName) {
|
|
96
|
+
layer.emissionShape = EmissionShapeType[shapeTypeName];
|
|
97
|
+
},
|
|
98
|
+
Object.keys(EmissionShapeType)
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const cEmissionFrom = addControl(
|
|
102
|
+
'emissionFrom',
|
|
103
|
+
function (layer, fromTypeName) {
|
|
104
|
+
layer.emissionFrom = EmissionFromType[fromTypeName];
|
|
105
|
+
},
|
|
106
|
+
Object.keys(EmissionFromType)
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const cEmissionRate = addControl('emissionRate', function (layer, rate) {
|
|
110
|
+
layer.emissionRate = rate;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const cEmissionImmediate = addControl('emissionImmediate', function (layer, value) {
|
|
114
|
+
layer.emissionImmediate = value;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const cVelocityAngle = addControl('velocityAngle', function (layer, value) {
|
|
118
|
+
layer.particleVelocityDirection.angle = value;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
this.addChild(dat);
|
|
122
|
+
|
|
123
|
+
const cVelocityDirection = this.addLabeledControlVertical('Velocity Direction', new Vector3Control());
|
|
124
|
+
const cLife = this.addLabeledControlVertical('Lifespan', new NumericIntervalControl());
|
|
125
|
+
const cSize = this.addLabeledControlVertical('Size', new NumericIntervalControl());
|
|
126
|
+
const cSpeed = this.addLabeledControlVertical('Speed', new NumericIntervalControl());
|
|
127
|
+
const cRotation = this.addLabeledControlVertical('Rotation', new NumericIntervalControl());
|
|
128
|
+
|
|
129
|
+
const cRotationSpeed = this.addLabeledControlVertical('Rotation Speed', new NumericIntervalControl());
|
|
130
|
+
|
|
131
|
+
const cPosition = this.addLabeledControlVertical('Position', new Vector3Control());
|
|
132
|
+
const cScale = this.addLabeledControlVertical('Scale', new Vector3Control());
|
|
133
|
+
|
|
134
|
+
const cParameters = this.addLabeledControlVertical('Parameters', new ListController(function () {
|
|
135
|
+
/**
|
|
136
|
+
*
|
|
137
|
+
* @type {ParticleLayer}
|
|
138
|
+
*/
|
|
139
|
+
const layer = self.model.getValue();
|
|
140
|
+
|
|
141
|
+
const availableNames = Object.values(ParticleParameters);
|
|
142
|
+
|
|
143
|
+
layer.parameterTracks.forEach(function (track) {
|
|
144
|
+
const trackName = track.name;
|
|
145
|
+
const i = availableNames.indexOf(trackName);
|
|
146
|
+
if (i !== -1) {
|
|
147
|
+
availableNames.splice(i, 1);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (availableNames.length === 0) {
|
|
152
|
+
//all named tracks already exist
|
|
153
|
+
throw new Error('all named tracks are already present');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const name = availableNames.pop();
|
|
157
|
+
|
|
158
|
+
let lutItemSize;
|
|
159
|
+
|
|
160
|
+
if (name === ParticleParameters.Color) {
|
|
161
|
+
lutItemSize = 4;
|
|
162
|
+
} else if (name === ParticleParameters.Scale) {
|
|
163
|
+
lutItemSize = 1;
|
|
164
|
+
} else {
|
|
165
|
+
throw new Error(`Unsupported parameter '${name}'`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const lut = new ParameterLookupTable(lutItemSize);
|
|
169
|
+
|
|
170
|
+
return new ParameterTrack(name, lut);
|
|
171
|
+
}, function () {
|
|
172
|
+
return new ParameterTrackController();
|
|
173
|
+
}));
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
* @param {ParticleLayer} layer
|
|
178
|
+
* @param {ParticleLayer} oldLayer
|
|
179
|
+
*/
|
|
180
|
+
function handleModelSet(layer, oldLayer) {
|
|
181
|
+
if (layer !== null) {
|
|
182
|
+
surrogate.imageURL = layer.imageURL;
|
|
183
|
+
surrogate.emissionShape = enumNameByValue(layer.emissionShape, EmissionShapeType);
|
|
184
|
+
surrogate.emissionFrom = enumNameByValue(layer.emissionFrom, EmissionFromType);
|
|
185
|
+
surrogate.emissionRate = layer.emissionRate;
|
|
186
|
+
surrogate.emissionImmediate = layer.emissionImmediate;
|
|
187
|
+
surrogate.velocityAngle = layer.particleVelocityDirection.angle;
|
|
188
|
+
|
|
189
|
+
cImageURL.setValue(surrogate.imageURL);
|
|
190
|
+
cEmissionShape.setValue(surrogate.emissionShape);
|
|
191
|
+
cEmissionFrom.setValue(surrogate.emissionFrom);
|
|
192
|
+
cEmissionRate.setValue(surrogate.emissionRate);
|
|
193
|
+
cEmissionImmediate.setValue(surrogate.emissionImmediate);
|
|
194
|
+
cVelocityAngle.setValue(surrogate.velocityAngle);
|
|
195
|
+
|
|
196
|
+
cLife.model.set(layer.particleLife);
|
|
197
|
+
cSize.model.set(layer.particleSize);
|
|
198
|
+
cSpeed.model.set(layer.particleSpeed);
|
|
199
|
+
cRotation.model.set(layer.particleRotation);
|
|
200
|
+
cRotationSpeed.model.set(layer.particleRotationSpeed);
|
|
201
|
+
cPosition.model.set(layer.position);
|
|
202
|
+
cScale.model.set(layer.scale);
|
|
203
|
+
cVelocityDirection.model.set(layer.particleVelocityDirection.direction);
|
|
204
|
+
cParameters.model.set(layer.parameterTracks.tracks);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
this.model.onChanged.add(handleModelSet);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
export default ParticleLayerController;
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import GuiControl from "../../../../../src/view/controller/controls/GuiControl.js";
|
|
2
|
+
import View from "../../../../../src/view/View.js";
|
|
3
|
+
import { PointerDevice } from "../../../../../src/engine/input/devices/PointerDevice.js";
|
|
4
|
+
import Vector2 from "../../../../../src/core/geom/Vector2.js";
|
|
5
|
+
import {
|
|
6
|
+
ParameterLookupTableFlags
|
|
7
|
+
} from "../../../../../src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTableFlags.js";
|
|
8
|
+
import LabelView from "../../../../../src/view/common/LabelView.js";
|
|
9
|
+
import Vector1 from "../../../../../src/core/geom/Vector1.js";
|
|
10
|
+
import { clamp01 } from "../../../../../src/core/math/clamp01.js";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
function computeVerticalValuePosition(v, min, max, height, lineWidth) {
|
|
14
|
+
const margin = height * 0.15;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const valueRange = max - min;
|
|
18
|
+
|
|
19
|
+
const drawRangeY = height - lineWidth - margin * 2;
|
|
20
|
+
const drawOffsetY = lineWidth / 2 + margin;
|
|
21
|
+
|
|
22
|
+
let normalizedValue;
|
|
23
|
+
|
|
24
|
+
if (valueRange === 0) {
|
|
25
|
+
normalizedValue = 0.5;
|
|
26
|
+
} else {
|
|
27
|
+
normalizedValue = (v - min) / (valueRange);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const scaledValue = (1 - normalizedValue) * drawRangeY + drawOffsetY;
|
|
31
|
+
|
|
32
|
+
return scaledValue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param level
|
|
38
|
+
* @param {CanvasRenderingContext2D} context2d
|
|
39
|
+
* @param width
|
|
40
|
+
* @param height
|
|
41
|
+
* @param {ParameterLookupTable} lut
|
|
42
|
+
* @param lineWidth
|
|
43
|
+
*/
|
|
44
|
+
function drawVerticalLine(level, context2d, width, height, lut, lineWidth) {
|
|
45
|
+
|
|
46
|
+
context2d.fillStyle = 'none';
|
|
47
|
+
context2d.strokeStyle = 'rgba(255,0,0,1)';
|
|
48
|
+
context2d.lineWidth = lineWidth;
|
|
49
|
+
|
|
50
|
+
lut.computeStatistics();
|
|
51
|
+
|
|
52
|
+
//figure out Y coordinate
|
|
53
|
+
const y = computeVerticalValuePosition(level, lut.valueMin, lut.valueMax, height, lineWidth);
|
|
54
|
+
|
|
55
|
+
context2d.beginPath();
|
|
56
|
+
|
|
57
|
+
context2d.moveTo(0, y);
|
|
58
|
+
|
|
59
|
+
context2d.lineTo(width, y);
|
|
60
|
+
|
|
61
|
+
context2d.stroke();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param {CanvasRenderingContext2D} context2d
|
|
67
|
+
* @param {number} width
|
|
68
|
+
* @param {number} height
|
|
69
|
+
* @param {ParameterLookupTable} lut
|
|
70
|
+
* @param {number} lineWidth
|
|
71
|
+
*/
|
|
72
|
+
function drawPlot(context2d, width, height, lut, lineWidth) {
|
|
73
|
+
context2d.fillStyle = 'none';
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
context2d.strokeStyle = 'rgba(255,255,255,1)';
|
|
77
|
+
context2d.lineWidth = lineWidth;
|
|
78
|
+
|
|
79
|
+
context2d.beginPath();
|
|
80
|
+
|
|
81
|
+
lut.computeStatistics();
|
|
82
|
+
|
|
83
|
+
let i;
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
const numValues = lut.positions.length;
|
|
87
|
+
|
|
88
|
+
for (i = 0; i < numValues; i++) {
|
|
89
|
+
const j = i * lut.itemSize;
|
|
90
|
+
const datum = lut.data[j];
|
|
91
|
+
const position = lut.positions[i];
|
|
92
|
+
|
|
93
|
+
const x = position * width;
|
|
94
|
+
|
|
95
|
+
const scaledValue = computeVerticalValuePosition(datum, lut.valueMin, lut.valueMax, height, lineWidth);
|
|
96
|
+
|
|
97
|
+
if (i === 0) {
|
|
98
|
+
if (position !== 0) {
|
|
99
|
+
context2d.moveTo(0, scaledValue);
|
|
100
|
+
context2d.lineTo(x, scaledValue);
|
|
101
|
+
} else {
|
|
102
|
+
context2d.moveTo(x, scaledValue);
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
context2d.lineTo(x, scaledValue);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if (i === numValues - 1 && position !== 1) {
|
|
110
|
+
context2d.lineTo(width, scaledValue);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
context2d.stroke();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function buildMarker(markers, model, update, canvas) {
|
|
120
|
+
const marker = new MarkerView();
|
|
121
|
+
|
|
122
|
+
const pMarker = new PointerDevice(marker.el);
|
|
123
|
+
const pGlobal = new PointerDevice(window);
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
const dragAnchor = new Vector2();
|
|
127
|
+
let dragScale;
|
|
128
|
+
let oldValue, oldPosition;
|
|
129
|
+
|
|
130
|
+
let dragging = false;
|
|
131
|
+
|
|
132
|
+
function handleMove(position, event) {
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
event.stopPropagation();
|
|
135
|
+
|
|
136
|
+
const delta = position.clone().sub(dragAnchor);
|
|
137
|
+
|
|
138
|
+
const markerIndex = markers.indexOf(marker);
|
|
139
|
+
|
|
140
|
+
if (markerIndex === -1) {
|
|
141
|
+
//dead marker
|
|
142
|
+
pMarker.stop();
|
|
143
|
+
pGlobal.stop();
|
|
144
|
+
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const lut = model();
|
|
149
|
+
|
|
150
|
+
const positionDelta = delta.x / canvas.width;
|
|
151
|
+
|
|
152
|
+
const valueDeltaNormalized = (-delta.y / canvas.height);
|
|
153
|
+
|
|
154
|
+
const valueDelta = valueDeltaNormalized * dragScale;
|
|
155
|
+
|
|
156
|
+
const newPosition = clamp01(oldPosition + positionDelta);
|
|
157
|
+
|
|
158
|
+
lut.positions[markerIndex] = newPosition;
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
const newValue = oldValue + valueDelta;
|
|
162
|
+
|
|
163
|
+
lut.data[markerIndex * lut.itemSize] = newValue;
|
|
164
|
+
|
|
165
|
+
update();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function handleDragEnd() {
|
|
169
|
+
pGlobal.on.move.remove(handleMove);
|
|
170
|
+
pGlobal.on.up.remove(handleDragEnd);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
pGlobal.on.down.add(function (position) {
|
|
174
|
+
dragAnchor.copy(position);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
pMarker.on.down.add(function (position, event) {
|
|
178
|
+
if (event.which === 2) {
|
|
179
|
+
//middle mouse button
|
|
180
|
+
|
|
181
|
+
event.preventDefault();
|
|
182
|
+
event.stopPropagation();
|
|
183
|
+
|
|
184
|
+
const markerIndex = markers.indexOf(marker);
|
|
185
|
+
|
|
186
|
+
if (markerIndex === -1) {
|
|
187
|
+
//dead marker
|
|
188
|
+
pMarker.stop();
|
|
189
|
+
pGlobal.stop();
|
|
190
|
+
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const lut = model();
|
|
195
|
+
|
|
196
|
+
lut.positions.splice(markerIndex, 1);
|
|
197
|
+
lut.data.splice(markerIndex * lut.itemSize, lut.itemSize);
|
|
198
|
+
|
|
199
|
+
update();
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
pMarker.on.dragStart.add(function () {
|
|
204
|
+
dragging = true;
|
|
205
|
+
|
|
206
|
+
const lut = model();
|
|
207
|
+
|
|
208
|
+
dragScale = lut.valueMax - lut.valueMin;
|
|
209
|
+
if (dragScale === 0) {
|
|
210
|
+
dragScale = 0.1;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const markerIndex = markers.indexOf(marker);
|
|
214
|
+
|
|
215
|
+
oldValue = lut.data[markerIndex * lut.itemSize];
|
|
216
|
+
oldPosition = lut.positions[markerIndex];
|
|
217
|
+
|
|
218
|
+
pGlobal.on.move.add(handleMove);
|
|
219
|
+
pGlobal.on.up.add(handleDragEnd);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
pMarker.start();
|
|
223
|
+
pGlobal.start();
|
|
224
|
+
|
|
225
|
+
return marker;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
class MarkerView extends View {
|
|
230
|
+
constructor() {
|
|
231
|
+
super();
|
|
232
|
+
|
|
233
|
+
this.el = document.createElement('div');
|
|
234
|
+
|
|
235
|
+
this.el.classList.add('marker-view');
|
|
236
|
+
|
|
237
|
+
//add value label
|
|
238
|
+
this.value = new Vector2(0, 0);
|
|
239
|
+
|
|
240
|
+
const yValue = new Vector1(0);
|
|
241
|
+
|
|
242
|
+
const lY = new LabelView(yValue, { classList: ['value'] });
|
|
243
|
+
|
|
244
|
+
this.addChild(lY);
|
|
245
|
+
|
|
246
|
+
this.value.onChanged.add((x, y) => yValue.set(y));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
export class ScalarParameterLUTController extends GuiControl {
|
|
252
|
+
constructor() {
|
|
253
|
+
super();
|
|
254
|
+
|
|
255
|
+
this.el.classList.add('scalar-parameter-lut-controller');
|
|
256
|
+
|
|
257
|
+
const lineWidth = 2;
|
|
258
|
+
|
|
259
|
+
const self = this;
|
|
260
|
+
|
|
261
|
+
const canvas = document.createElement('canvas');
|
|
262
|
+
canvas.width = 170;
|
|
263
|
+
|
|
264
|
+
const context2d = canvas.getContext('2d');
|
|
265
|
+
|
|
266
|
+
const vCanvas = new View();
|
|
267
|
+
vCanvas.el = canvas;
|
|
268
|
+
|
|
269
|
+
const markers = [];
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
*
|
|
273
|
+
* @returns {ParameterLookupTable}
|
|
274
|
+
*/
|
|
275
|
+
function model() {
|
|
276
|
+
return self.model.getValue();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function updatePlot() {
|
|
280
|
+
const h = canvas.height;
|
|
281
|
+
const w = canvas.width;
|
|
282
|
+
|
|
283
|
+
context2d.clearRect(0, 0, w, h);
|
|
284
|
+
context2d.fillStyle = 'black';
|
|
285
|
+
context2d.fillRect(0, 0, w, h);
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
*
|
|
290
|
+
* @type {ParameterLookupTable}
|
|
291
|
+
*/
|
|
292
|
+
const lut = self.model.getValue();
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
if (lut !== null) {
|
|
296
|
+
//draw a line through zero on Y axis
|
|
297
|
+
drawVerticalLine(0, context2d, w, h, lut, 1);
|
|
298
|
+
|
|
299
|
+
drawPlot(context2d, w, h, lut, lineWidth);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function createMarker() {
|
|
304
|
+
const marker = buildMarker(markers, model, update, canvas);
|
|
305
|
+
|
|
306
|
+
markers.push(marker);
|
|
307
|
+
self.addChild(marker);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function resizeMarkerPool(size) {
|
|
311
|
+
while (size < markers.length) {
|
|
312
|
+
const marker = markers.pop();
|
|
313
|
+
self.removeChild(marker);
|
|
314
|
+
}
|
|
315
|
+
while (size > markers.length) {
|
|
316
|
+
createMarker();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function updateMarkers() {
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
*
|
|
324
|
+
* @type {ParameterLookupTable}
|
|
325
|
+
*/
|
|
326
|
+
const lut = model();
|
|
327
|
+
|
|
328
|
+
if (lut !== null) {
|
|
329
|
+
const positions = lut.positions;
|
|
330
|
+
|
|
331
|
+
const numValues = positions.length;
|
|
332
|
+
|
|
333
|
+
//resize marker pool
|
|
334
|
+
resizeMarkerPool(numValues);
|
|
335
|
+
|
|
336
|
+
//move markers
|
|
337
|
+
for (let i = 0; i < numValues; i++) {
|
|
338
|
+
const marker = markers[i];
|
|
339
|
+
|
|
340
|
+
const position = positions[i];
|
|
341
|
+
|
|
342
|
+
const datum = lut.data[i * lut.itemSize];
|
|
343
|
+
|
|
344
|
+
const y = computeVerticalValuePosition(datum, lut.valueMin, lut.valueMax, canvas.height, lineWidth);
|
|
345
|
+
|
|
346
|
+
const x = position * canvas.width;
|
|
347
|
+
|
|
348
|
+
marker.value.set(position, datum);
|
|
349
|
+
marker.position.set(x, y);
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
//clear all markers
|
|
353
|
+
resizeMarkerPool(0);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function update() {
|
|
358
|
+
updatePlot();
|
|
359
|
+
updateMarkers();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const pCanvas = new PointerDevice(canvas);
|
|
363
|
+
|
|
364
|
+
pCanvas.on.down.add(function (position, event) {
|
|
365
|
+
const p = event.offsetX / canvas.width;
|
|
366
|
+
|
|
367
|
+
const valueNormalized = event.offsetY / canvas.height;
|
|
368
|
+
|
|
369
|
+
const lut = model();
|
|
370
|
+
|
|
371
|
+
lut.setFlag(ParameterLookupTableFlags.WriteMode);
|
|
372
|
+
if (lut.positions.length > 0) {
|
|
373
|
+
|
|
374
|
+
//ensure that statistics are present
|
|
375
|
+
lut.computeStatistics();
|
|
376
|
+
|
|
377
|
+
const valueMin = lut.valueMin;
|
|
378
|
+
const valueMax = lut.valueMax;
|
|
379
|
+
|
|
380
|
+
const valueRange = valueMax - valueMin;
|
|
381
|
+
const value = (1 - valueNormalized) * valueRange + valueMin;
|
|
382
|
+
|
|
383
|
+
lut.addValue(p, [value]);
|
|
384
|
+
} else {
|
|
385
|
+
lut.addValue(p, [0]);
|
|
386
|
+
lut.computeStatistics();
|
|
387
|
+
}
|
|
388
|
+
lut.clearFlag(ParameterLookupTableFlags.WriteMode);
|
|
389
|
+
|
|
390
|
+
update();
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
pCanvas.start();
|
|
394
|
+
|
|
395
|
+
this.addChild(vCanvas);
|
|
396
|
+
|
|
397
|
+
this.model.onChanged.add(function () {
|
|
398
|
+
update();
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import GuiControl from "../../../../../src/view/controller/controls/GuiControl.js";
|
|
2
|
+
import { NativeListController } from "../../../../../src/view/controller/controls/NativeListController.js";
|
|
3
|
+
import { AttachmentSocket } from "../../../../../src/engine/ecs/sockets/AttachmentSocket.js";
|
|
4
|
+
import EmptyView from "../../../../../src/view/elements/EmptyView.js";
|
|
5
|
+
import DatGuiController from "../DatGuiController.js";
|
|
6
|
+
import TransformController from "../TransformController.js";
|
|
7
|
+
|
|
8
|
+
export class AttachmentSocketsController extends GuiControl {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
this.model.onChanged.add(this.__handleModelChange, this);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {AttachmentSockets} model
|
|
18
|
+
* @param {AttachmentSockets} model_old
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
__handleModelChange(model, model_old) {
|
|
22
|
+
|
|
23
|
+
if (model_old !== null) {
|
|
24
|
+
this.removeAllChildren();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (model !== null) {
|
|
28
|
+
this.addChild(new NativeListController({
|
|
29
|
+
model: model.elements,
|
|
30
|
+
elementFactory() {
|
|
31
|
+
return new AttachmentSocket();
|
|
32
|
+
},
|
|
33
|
+
elementViewFactory(socket) {
|
|
34
|
+
const v = new EmptyView();
|
|
35
|
+
|
|
36
|
+
const c = new DatGuiController();
|
|
37
|
+
|
|
38
|
+
c.add(socket, 'id');
|
|
39
|
+
|
|
40
|
+
v.addChild(c);
|
|
41
|
+
const tc = new TransformController();
|
|
42
|
+
tc.model.set(socket.transform);
|
|
43
|
+
v.addChild(tc);
|
|
44
|
+
|
|
45
|
+
return v;
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|