@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.
Files changed (175) hide show
  1. package/editor/Editor.js +793 -0
  2. package/editor/SelectionVisualizer.js +148 -0
  3. package/editor/actions/concrete/ActionUpdateTexture.js +21 -0
  4. package/editor/actions/concrete/ArrayCopyAction.js +39 -0
  5. package/editor/actions/concrete/ComponentAddAction.js +47 -0
  6. package/editor/actions/concrete/ComponentRemoveAction.js +38 -0
  7. package/editor/actions/concrete/EntityCreateAction.js +47 -0
  8. package/editor/actions/concrete/EntityRemoveAction.js +51 -0
  9. package/editor/actions/concrete/ModifyPatchSampler2DAction.js +118 -0
  10. package/editor/actions/concrete/ModifyPatchSampler2DAction.spec.js +30 -0
  11. package/editor/actions/concrete/ModifyPatchTextureArray2DAction.js +182 -0
  12. package/editor/actions/concrete/PaintTerrainOverlayAction.js +45 -0
  13. package/editor/actions/concrete/PatchTerrainHeightAction.js +67 -0
  14. package/editor/actions/concrete/PatchTerrainTextureAction.js +152 -0
  15. package/editor/actions/concrete/SelectionAddAction.js +36 -0
  16. package/editor/actions/concrete/SelectionClearAction.js +22 -0
  17. package/editor/actions/concrete/SelectionRemoveAction.js +30 -0
  18. package/editor/actions/concrete/TransformModifyAction.js +46 -0
  19. package/editor/actions/concrete/WriteGridValueAction.js +46 -0
  20. package/editor/ecs/EditorEntity.js +12 -0
  21. package/editor/ecs/EditorEntitySystem.js +14 -0
  22. package/editor/ecs/component/FieldDescriptor.js +34 -0
  23. package/editor/ecs/component/FieldValueAdapter.js +20 -0
  24. package/editor/ecs/component/TypeEditor.js +33 -0
  25. package/editor/ecs/component/TypeSchema.d.ts +38 -0
  26. package/editor/ecs/component/createFieldEditor.js +92 -0
  27. package/editor/ecs/component/createObjectEditor.js +361 -0
  28. package/editor/ecs/component/editors/ColorEditor.js +39 -0
  29. package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
  30. package/editor/ecs/component/editors/ImagePathEditor.js +82 -0
  31. package/editor/ecs/component/editors/LargeStrongEditor.js +107 -0
  32. package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
  33. package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
  34. package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
  35. package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
  36. package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
  37. package/editor/ecs/component/editors/Sampler2DEditor.js +221 -0
  38. package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
  39. package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
  40. package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
  41. package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
  42. package/editor/ecs/component/editors/common/noEditor.js +9 -0
  43. package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
  44. package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
  45. package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +225 -0
  46. package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
  47. package/editor/ecs/component/editors/ecs/ParameterTrackSetEditor.js +18 -0
  48. package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
  49. package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +58 -0
  50. package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
  51. package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
  52. package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
  53. package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
  54. package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +95 -0
  55. package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
  56. package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
  57. package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
  58. package/editor/ecs/component/editors/geom/QuaternionEditor.js +63 -0
  59. package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
  60. package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
  61. package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
  62. package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
  63. package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
  64. package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
  65. package/editor/ecs/component/editors/primitive/FunctionEditor.js +29 -0
  66. package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
  67. package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
  68. package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
  69. package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
  70. package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
  71. package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
  72. package/editor/ecs/component/editors/three/TextureEditor.js +112 -0
  73. package/editor/ecs/component/findNearestRegisteredType.js +59 -0
  74. package/editor/ecs/component/prototypeObjectEditor.js +379 -0
  75. package/editor/enableEditor.js +85 -0
  76. package/editor/library/MeshLibrary.js +33 -0
  77. package/editor/process/DisableGameUIProcess.js +43 -0
  78. package/editor/process/EditorProcess.js +35 -0
  79. package/editor/process/ObstacleGridDisplayProcess.js +120 -0
  80. package/editor/process/ProcessEngine.js +123 -0
  81. package/editor/process/SymbolicDisplayProcess.js +132 -0
  82. package/editor/process/symbolic/ComponentSymbolicDisplay.js +34 -0
  83. package/editor/process/symbolic/SymbolicDisplayInternalAPI.js +159 -0
  84. package/editor/process/symbolic/buildThreeJSHelperEntity.js +36 -0
  85. package/editor/process/symbolic/make3DSymbolicDisplay.js +91 -0
  86. package/editor/process/symbolic/makeCameraSymbolicDisplay.js +32 -0
  87. package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +176 -0
  88. package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
  89. package/editor/process/symbolic/makeHelperSphereGeometry.js +73 -0
  90. package/editor/process/symbolic/makeLightSymbolicDisplay.js +77 -0
  91. package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.js +146 -0
  92. package/editor/process/symbolic/makePathSymbolicDisplay.js +105 -0
  93. package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +74 -0
  94. package/editor/process/symbolic/makeSocketsSymbolicDisplay.js +153 -0
  95. package/editor/process/symbolic/makeSolidArrowGeometry.js +391 -0
  96. package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.js +89 -0
  97. package/editor/process/symbolic/makeStoryTriggerSetAreaDisplay.js +114 -0
  98. package/editor/process/symbolic/synchronizeTransform.js +50 -0
  99. package/editor/tools/FoliagePaintTool.js +168 -0
  100. package/editor/tools/GridPaintTool.js +247 -0
  101. package/editor/tools/SelectionTool.js +407 -0
  102. package/editor/tools/TopDownCameraControlTool.js +59 -0
  103. package/editor/tools/TransformTool.js +370 -0
  104. package/editor/tools/engine/Tool.js +121 -0
  105. package/editor/tools/engine/ToolEngine.js +193 -0
  106. package/editor/tools/engine/ToolState.js +9 -0
  107. package/editor/tools/engine/ToolStateMachine.js +53 -0
  108. package/editor/tools/paint/TerrainHeightPaintTool.js +297 -0
  109. package/editor/tools/paint/TerrainPaintTool.js +211 -0
  110. package/editor/tools/paint/TerrainTexturePaintTool.js +193 -0
  111. package/editor/tools/paint/prototypeTerrainEditor.js +135 -0
  112. package/editor/tools/v2/BlenderCameraOrientationGizmo.d.ts +50 -0
  113. package/editor/tools/v2/BlenderCameraOrientationGizmo.js +500 -0
  114. package/editor/tools/v2/TransformControls.d.ts +20 -0
  115. package/editor/tools/v2/TransformControls.js +1782 -0
  116. package/editor/tools/v2/prototypeTransformControls.js +92 -0
  117. package/editor/view/EditorView.js +462 -0
  118. package/editor/view/GridPickCoordinateView.js +88 -0
  119. package/editor/view/ecs/ComponentControlFactory.js +48 -0
  120. package/editor/view/ecs/ComponentControlView.js +214 -0
  121. package/editor/view/ecs/EntityEditor.js +258 -0
  122. package/editor/view/ecs/EntityList.js +258 -0
  123. package/editor/view/ecs/components/BlackboardController.js +50 -0
  124. package/editor/view/ecs/components/DatGuiController.js +216 -0
  125. package/editor/view/ecs/components/FogOfWarController.js +78 -0
  126. package/editor/view/ecs/components/FogOfWarRevealerController.js +44 -0
  127. package/editor/view/ecs/components/GeneratedArmyController.js +42 -0
  128. package/editor/view/ecs/components/GridObstacleController.js +72 -0
  129. package/editor/view/ecs/components/GridPositionController.js +40 -0
  130. package/editor/view/ecs/components/HeadsUpDisplayController.js +30 -0
  131. package/editor/view/ecs/components/HighlightController.js +47 -0
  132. package/editor/view/ecs/components/MeshController.js +125 -0
  133. package/editor/view/ecs/components/PathFollowerController.js +87 -0
  134. package/editor/view/ecs/components/TagController.js +80 -0
  135. package/editor/view/ecs/components/TerrainController.js +225 -0
  136. package/editor/view/ecs/components/TransformController.js +103 -0
  137. package/editor/view/ecs/components/UnitShopController.js +112 -0
  138. package/editor/view/ecs/components/army/ArmyController.js +130 -0
  139. package/editor/view/ecs/components/color/GaugeView.js +107 -0
  140. package/editor/view/ecs/components/common/AutoCanvasView.js +53 -0
  141. package/editor/view/ecs/components/common/LineView.js +17 -0
  142. package/editor/view/ecs/components/common/NumberController.js +112 -0
  143. package/editor/view/ecs/components/common/NumericIntervalController.js +64 -0
  144. package/editor/view/ecs/components/gui/GUIElementController.js +117 -0
  145. package/editor/view/ecs/components/items/ItemContainerController.js +132 -0
  146. package/editor/view/ecs/components/items/ItemContainerController.stories.js +50 -0
  147. package/editor/view/ecs/components/items/ItemController.js +52 -0
  148. package/editor/view/ecs/components/particles/ColorParameterLUTController.js +444 -0
  149. package/editor/view/ecs/components/particles/ParameterTrackController.js +51 -0
  150. package/editor/view/ecs/components/particles/ParticleEmitterController.js +213 -0
  151. package/editor/view/ecs/components/particles/ParticleLayerController.js +213 -0
  152. package/editor/view/ecs/components/particles/ScalarParameterLUTController.js +401 -0
  153. package/editor/view/ecs/components/sockets/AttachmentSocketsController.js +51 -0
  154. package/editor/view/ecs/components/sound/SoundEmitterController.js +137 -0
  155. package/editor/view/ecs/components/story/StoryTriggerSetController.js +214 -0
  156. package/editor/view/ecs/components/unit/AuraController.js +45 -0
  157. package/editor/view/library/MeshLibraryView.js +164 -0
  158. package/editor/view/node-graph/NodeGraphEditorView.js +170 -0
  159. package/editor/view/node-graph/NodeGraphView.js +453 -0
  160. package/editor/view/node-graph/NodeView.js +135 -0
  161. package/editor/view/node-graph/PortView.js +69 -0
  162. package/editor/view/process/ProcessView.js +63 -0
  163. package/editor/view/tools/ToolSettingsView.js +143 -0
  164. package/editor/view/tools/ToolView.js +58 -0
  165. package/package.json +2 -1
  166. package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +6 -1
  167. package/src/core/geom/3d/aabb/aabb3_matrix4_project.js +1 -1
  168. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts +9 -0
  169. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +148 -9
  170. package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +21 -1
  171. package/src/engine/graphics/render/forward_plus/LightManager.js +0 -60
  172. package/src/engine/graphics/render/forward_plus/LightRenderMetadata.js +1 -3
  173. package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
  174. package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.d.ts +0 -3
  175. package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +0 -11
@@ -0,0 +1,391 @@
1
+ import { StreamGeometryBuilder } from "../../../src/engine/graphics/ecs/path/tube/build/StreamGeometryBuilder.js";
2
+ import { make_ring_faces } from "../../../src/engine/graphics/ecs/path/tube/build/make_ring_faces.js";
3
+ import { BufferGeometry } from "three/src/core/BufferGeometry.js";
4
+ import { Float32BufferAttribute } from "three/src/core/BufferAttribute.js";
5
+ import { Vector2, Vector3 } from "three";
6
+
7
+ // Modified from https://github.com/mrdoob/three.js/blob/master/src/geometries/CylinderBufferGeometry.js
8
+ class ArrowBufferGeometry extends BufferGeometry {
9
+
10
+ constructor( {radiusTop = 1/7, radiusBottom = 1/20, height = 1, heightTop = 0.6, radialSegments = 8, heightSegments = 1, openEnded = false, heightIncludesHead = true} = {} ) {
11
+
12
+ super();
13
+ this.type = 'ArrowBufferGeometry';
14
+
15
+ this.parameters = {
16
+ radiusTop: radiusTop,
17
+ radiusBottom: radiusBottom,
18
+ height: height,
19
+ heightTop: heightTop,
20
+ radialSegments: radialSegments,
21
+ heightSegments: heightSegments,
22
+ openEnded: openEnded,
23
+ heightIncludesHead: heightIncludesHead,
24
+ };
25
+
26
+ const scope = this;
27
+ const thetaStart = 0, thetaLength = 2 * Math.PI;
28
+
29
+ radialSegments = Math.floor( radialSegments );
30
+ heightSegments = Math.floor( heightSegments );
31
+
32
+ // buffers
33
+
34
+ const indices = [];
35
+ const vertices = [];
36
+ const normals = [];
37
+ const uvs = [];
38
+
39
+ // helper variables
40
+
41
+ let index = 0;
42
+ const indexArray = [];
43
+ const halfHeight = height / 2;
44
+ const tubeHeight = heightIncludesHead ? height - heightTop : height;
45
+ let groupStart = 0;
46
+
47
+ // generate geometry
48
+
49
+ generateTorso();
50
+ generateCap( true );
51
+ generateCap( false, true );
52
+
53
+ if ( openEnded === false ) {
54
+
55
+ if ( radiusBottom > 0 ) generateCap( false );
56
+
57
+ }
58
+
59
+ // build geometry
60
+
61
+ this.setIndex( indices );
62
+ this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
63
+ this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
64
+ this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
65
+
66
+ function generateTorso() {
67
+
68
+ const normal = new Vector3();
69
+ const vertex = new Vector3();
70
+
71
+ let groupCount = 0;
72
+
73
+ // this will be used to calculate the normal
74
+ const slope = 0;
75
+
76
+ // generate vertices, normals and uvs
77
+
78
+ for ( let y = 0; y <= heightSegments; y ++ ) {
79
+
80
+ const indexRow = [];
81
+
82
+ const v = y / heightSegments;
83
+
84
+ // calculate the radius of the current row
85
+
86
+ const radius = radiusBottom;
87
+
88
+ for ( let x = 0; x <= radialSegments; x ++ ) {
89
+
90
+ const u = x / radialSegments;
91
+
92
+ const theta = u * Math.PI * 2;
93
+
94
+ const sinTheta = Math.sin( theta );
95
+ const cosTheta = Math.cos( theta );
96
+
97
+ // vertex
98
+
99
+ vertex.x = radius * cosTheta;
100
+ vertex.y = radius * sinTheta;
101
+ vertex.z = v * tubeHeight;
102
+ vertices.push( vertex.x, vertex.y, vertex.z );
103
+
104
+ // normal
105
+
106
+ normal.set( cosTheta, sinTheta, 0 ).normalize();
107
+ normals.push( normal.x, normal.y, normal.z );
108
+
109
+ // uv
110
+
111
+ uvs.push( u, 1 - v );
112
+
113
+ // save index of vertex in respective row
114
+
115
+ indexRow.push( index ++ );
116
+
117
+ }
118
+
119
+ // now save vertices of the row in our index array
120
+
121
+ indexArray.push( indexRow );
122
+
123
+ }
124
+
125
+ // generate indices
126
+
127
+ for ( let x = 0; x < radialSegments; x ++ ) {
128
+
129
+ for ( let y = 0; y < heightSegments; y ++ ) {
130
+
131
+ // we use the index array to access the correct indices
132
+
133
+ const a = indexArray[ y ][ x ];
134
+ const b = indexArray[ y + 1 ][ x ];
135
+ const c = indexArray[ y + 1 ][ x + 1 ];
136
+ const d = indexArray[ y ][ x + 1 ];
137
+
138
+ // faces
139
+
140
+ indices.push( b, a, d );
141
+ indices.push( c, b, d );
142
+
143
+ // update group counter
144
+
145
+ groupCount += 6;
146
+
147
+ }
148
+
149
+ }
150
+
151
+ // add a group to the geometry. this will ensure multi material support
152
+
153
+ scope.addGroup( groupStart, groupCount, 0 );
154
+
155
+ // calculate new start value for groups
156
+
157
+ groupStart += groupCount;
158
+
159
+ }
160
+
161
+ function generateCap( top, headBase = false ) {
162
+
163
+ // save the index of the first center vertex
164
+ const centerIndexStart = index;
165
+
166
+ const uv = new Vector2();
167
+ const vertex = new Vector3();
168
+
169
+ let groupCount = 0;
170
+
171
+ const radius = ( top || headBase ) ? radiusTop : radiusBottom;
172
+ const sign = ( top ) ? 1 : -1;
173
+
174
+ // first we generate the center vertex data of the cap.
175
+ // because the geometry needs one set of uvs per face,
176
+ // we must generate a center vertex per face/segment
177
+
178
+ for ( let x = 1; x <= radialSegments; x ++ ) {
179
+
180
+ // vertex
181
+
182
+ vertices.push( 0, 0, top ? tubeHeight + heightTop : (headBase ? tubeHeight : 0) );
183
+
184
+ // normal
185
+
186
+ if (top) {
187
+ const theta = (x - 1/2) / radialSegments * Math.PI * 2;
188
+ const sinTheta = Math.sin(theta), cosTheta = Math.cos(theta);
189
+ const normal = new Vector3( cosTheta, sinTheta, radiusTop / heightTop );
190
+ normal.normalize();
191
+ normals.push( normal.x, normal.y, normal.z);
192
+ } else {
193
+ normals.push( 0, 0, sign );
194
+ }
195
+ // uv
196
+
197
+ uvs.push( 0.5, 0.5 );
198
+
199
+ // increase index
200
+
201
+ index ++;
202
+
203
+ }
204
+
205
+ // save the index of the last center vertex
206
+ const centerIndexEnd = index;
207
+
208
+ // now we generate the surrounding vertices, normals and uvs
209
+
210
+ for ( let x = 0; x <= radialSegments; x ++ ) {
211
+
212
+ const u = x / radialSegments;
213
+ const theta = u * thetaLength + thetaStart;
214
+
215
+ const cosTheta = Math.cos( theta );
216
+ const sinTheta = Math.sin( theta );
217
+
218
+ // vertex
219
+
220
+ vertex.x = radius * cosTheta;
221
+ vertex.y = radius * sinTheta;
222
+ vertex.z = top || headBase ? tubeHeight : 0;
223
+ vertices.push( vertex.x, vertex.y, vertex.z );
224
+
225
+ // normal
226
+
227
+ if (top) {
228
+ const normal = new Vector3(cosTheta, sinTheta, radiusTop / heightTop );
229
+ normal.normalize();
230
+ normals.push( normal.x, normal.y, normal.z);
231
+ } else {
232
+ normals.push( 0, 0, sign );
233
+ }
234
+ // uv
235
+
236
+ uv.x = ( cosTheta * 0.5 ) + 0.5;
237
+ uv.y = ( sinTheta * 0.5 * sign ) + 0.5;
238
+ uvs.push( uv.x, uv.y );
239
+
240
+ // increase index
241
+
242
+ index ++;
243
+
244
+ }
245
+
246
+ // generate indices
247
+
248
+ for ( let x = 0; x < radialSegments; x ++ ) {
249
+
250
+ const c = centerIndexStart + x;
251
+ const i = centerIndexEnd + x;
252
+
253
+ if ( top === true ) {
254
+
255
+ // face top
256
+
257
+ indices.push( i, i + 1, c );
258
+
259
+ } else {
260
+
261
+ // face bottom
262
+
263
+ indices.push( i + 1, i, c );
264
+
265
+ }
266
+
267
+ groupCount += 3;
268
+
269
+ }
270
+
271
+ // add a group to the geometry. this will ensure multi material support
272
+
273
+ scope.addGroup( groupStart, groupCount, top === true ? 1 : 2 );
274
+
275
+ // calculate new start value for groups
276
+
277
+ groupStart += groupCount;
278
+
279
+ }
280
+
281
+ }
282
+
283
+ }
284
+
285
+ /**
286
+ *
287
+ * @param {StreamGeometryBuilder} out
288
+ * @param {number} count
289
+ * @param {number} radius
290
+ * @param {number} z
291
+ */
292
+ function make_ring_vertices(out, count, radius, z) {
293
+
294
+ const positions = out.positions;
295
+
296
+ for (let i = 0; i < count; i++) {
297
+
298
+ const vertex_index = out.cursor_vertices++;
299
+
300
+ const fraction = i / count;
301
+
302
+ const angle = Math.PI * 2 * fraction;
303
+
304
+ const vertex_offset = vertex_index * 3;
305
+
306
+ positions[vertex_offset] = Math.cos(angle) * radius;
307
+ positions[vertex_offset + 1] = Math.sin(angle) * radius;
308
+ positions[vertex_offset + 2] = z;
309
+
310
+ }
311
+
312
+ }
313
+
314
+ /**
315
+ *
316
+ * @param {StreamGeometryBuilder} out
317
+ * @param {number} count
318
+ * @param {number} vertex_offset
319
+ * @param {number} tip_vertex_index
320
+ */
321
+ function make_cone_indices(out, count, vertex_offset, tip_vertex_index) {
322
+ const indices = out.indices;
323
+
324
+ for (let i = 0; i < count; i++) {
325
+ const index_0 = i + vertex_offset;
326
+ const index_1 = tip_vertex_index;
327
+ const index_2 = ((i + 1) % count) + vertex_offset;
328
+
329
+ const triangle_index = out.cursor_indices++;
330
+
331
+ const triangle_offset = triangle_index * 3;
332
+
333
+ indices[triangle_offset] = index_1;
334
+ indices[triangle_offset + 1] = index_2;
335
+ indices[triangle_offset + 2] = index_0;
336
+ }
337
+
338
+ }
339
+
340
+ export function makeSolidArrowGeometry(){
341
+ return new ArrowBufferGeometry();
342
+ }
343
+
344
+ function makeSolidArrowGeometry2(
345
+ radial_resolution = 16,
346
+ pointer_length = 0.5,
347
+ pointer_width = 0.2,
348
+ stem_width = 0.1
349
+ ) {
350
+
351
+ const Z_OFFSET = -0.5;
352
+
353
+ const vertex_count = radial_resolution * 3 + 1;
354
+
355
+ const triangle_count = radial_resolution //arrow cap
356
+ + radial_resolution * 2 // under-arrow ring
357
+ + radial_resolution * 2 // stem
358
+ + radial_resolution //cap for base of the stem
359
+ ;
360
+
361
+ const builder = new StreamGeometryBuilder();
362
+
363
+ builder.allocate(vertex_count, triangle_count);
364
+
365
+ const positions = builder.positions;
366
+
367
+ // write tip
368
+ const tip_vertex_index = builder.cursor_vertices++;
369
+ positions[tip_vertex_index * 3] = 0;
370
+ positions[tip_vertex_index * 3 + 1] = 0;
371
+ positions[tip_vertex_index * 3 + 2] = Z_OFFSET + 1;
372
+
373
+ const ring_0_start = builder.cursor_vertices;
374
+
375
+ // make cone ring - arrow cap
376
+ make_ring_vertices(builder, radial_resolution, pointer_width, Z_OFFSET + 1 - pointer_length);
377
+ make_cone_indices(builder, radial_resolution, ring_0_start, tip_vertex_index);
378
+
379
+ const ring_1_start = builder.cursor_vertices;
380
+
381
+ // make ring 1
382
+ make_ring_vertices(builder, radial_resolution, stem_width, Z_OFFSET + 1 - pointer_length);
383
+ make_ring_faces(builder, ring_1_start, 1, radial_resolution);
384
+
385
+ const ring_2_start = builder.cursor_vertices;
386
+
387
+ make_ring_vertices(builder, radial_resolution, stem_width, Z_OFFSET + 0);
388
+ make_ring_faces(builder, ring_2_start, 1, radial_resolution);
389
+
390
+ return builder.build();
391
+ }
@@ -0,0 +1,89 @@
1
+ import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
2
+ import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
3
+ import { SoundEmitter } from "../../../src/engine/sound/ecs/emitter/SoundEmitter.js";
4
+ import { makeHelperSphereGeometry } from "./makeHelperSphereGeometry.js";
5
+ import { Group, Line, LineBasicMaterial } from "three";
6
+ import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
7
+
8
+ /**
9
+ *
10
+ * @param {Engine} engine
11
+ */
12
+ export function makeSoundEmitterSymbolicDisplay(engine) {
13
+
14
+ const sphereGeometry = makeHelperSphereGeometry(1, 64);
15
+
16
+ const material_distance_max = new LineBasicMaterial({
17
+ depthTest: true,
18
+ depthWrite: true,
19
+ transparent: true,
20
+ linewidth: 1,
21
+ fog: false,
22
+ color: '#ffff00',
23
+ opacity: 0.5
24
+ });
25
+
26
+ const material_distance_min = new LineBasicMaterial({
27
+ depthTest: true,
28
+ depthWrite: true,
29
+ transparent: true,
30
+ linewidth: 1,
31
+ fog: false,
32
+ color: '#ffaa00'
33
+ });
34
+
35
+ /**
36
+ *
37
+ * @param {SoundEmitter} emitter
38
+ * @param {Transform} transform
39
+ * @param {number} entity
40
+ * @param {SymbolicDisplayInternalAPI} api
41
+ * @returns {EntityBuilder}
42
+ */
43
+ function factory([emitter, transform, entity], api) {
44
+
45
+ const group = new Group();
46
+ group.frustumCulled = false;
47
+
48
+
49
+ const mDistanceMax = new Line(sphereGeometry, material_distance_max);
50
+ mDistanceMax.scale.setScalar(emitter.distanceMax);
51
+ //draw on top of everything else
52
+ mDistanceMax.renderOrder = 9999;
53
+
54
+ const mDistanceMin = new Line(sphereGeometry, material_distance_min);
55
+ mDistanceMin.scale.setScalar(emitter.distanceMin);
56
+ //draw on top of everything else
57
+ mDistanceMin.renderOrder = 9999;
58
+
59
+ group.add(mDistanceMin);
60
+ group.add(mDistanceMax);
61
+
62
+ const builder = buildThreeJSHelperEntity(group);
63
+
64
+ /**
65
+ *
66
+ * @type {Transform}
67
+ */
68
+ const t = builder.getComponent(Transform);
69
+
70
+ function update() {
71
+ t.position.copy(transform.position);
72
+ t.rotation.copy(transform.rotation);
73
+ }
74
+
75
+ update();
76
+
77
+ api.bind(transform.position.onChanged, update);
78
+ api.bind(transform.rotation.onChanged, update);
79
+ api.bind(transform.scale.onChanged, update);
80
+
81
+ api.emit(builder);
82
+ }
83
+
84
+ return make3DSymbolicDisplay({
85
+ engine,
86
+ components: [SoundEmitter, Transform],
87
+ factory
88
+ });
89
+ }
@@ -0,0 +1,114 @@
1
+ import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
2
+ import { StoryTriggerSet } from "../../../../model/game/story/triggers/StoryTriggerSet.js";
3
+ import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
4
+ import { Group } from "three";
5
+ import AABB2 from "../../../src/core/geom/AABB2.js";
6
+
7
+
8
+ //TODO Work in progress
9
+
10
+ export function makeStoryTriggerSetAreaDisplay(engine) {
11
+ const COORDINATE_X = 'player.position.x';
12
+ const COORDINATE_Y = 'player.position.y';
13
+
14
+ /**
15
+ *
16
+ * @param {ReactiveExpression} exp
17
+ */
18
+ function isVarX(exp) {
19
+ return exp.isReference && exp.name === COORDINATE_X;
20
+ }
21
+
22
+ /**
23
+ *
24
+ * @param {ReactiveExpression} exp
25
+ */
26
+ function isVarY(exp) {
27
+ return exp.isReference && exp.name === COORDINATE_X;
28
+ }
29
+
30
+ /**
31
+ *
32
+ * @param {StoryTriggerSet} triggerSet
33
+ * @param entity
34
+ * @param {SymbolicDisplayInternalAPI} api
35
+ */
36
+ function factory([triggerSet, entity], api) {
37
+ const group = new Group();
38
+ group.frustumCulled = false;
39
+
40
+ const ecd = engine.entityManager.dataset;
41
+
42
+
43
+ /**
44
+ *
45
+ * @param {StoryTrigger} trigger
46
+ */
47
+ function processTrigger(trigger) {
48
+ const constraint = new AABB2(-Infinity, -Infinity, Infinity, Infinity);
49
+
50
+ /**
51
+ *
52
+ * @param {ReactiveExpression} constraint
53
+ */
54
+ function gt_x(constraint) {
55
+
56
+ }
57
+
58
+ /**
59
+ *
60
+ * @param {ReactiveExpression} constraint
61
+ */
62
+ function eq_x(constraint) {
63
+
64
+ }
65
+
66
+ trigger.condition.getExpression().traverse(exp => {
67
+ if (exp.isBinaryExpression && exp.isComparativeExpression) {
68
+ if (exp.isReactiveEquals) {
69
+ if (isVarX(exp.left)) {
70
+ eq_x(exp.right);
71
+ } else if (isVarX(exp.right)) {
72
+ eq_x(exp.right);
73
+ }
74
+ }
75
+
76
+ }
77
+ });
78
+
79
+ const lines = [];
80
+
81
+ // build lines
82
+
83
+ //TOP
84
+ if (Number.isFinite(constraint.y0)) {
85
+ lines.push(constraint.x0, constraint.y0, constraint.x1, constraint.y0);
86
+ }
87
+ //Bottom
88
+ if (Number.isFinite(constraint.y1)) {
89
+ lines.push(constraint.x0, constraint.y1, constraint.x1, constraint.y1);
90
+ }
91
+ //LEFT
92
+ if (Number.isFinite(constraint.x0)) {
93
+ lines.push(constraint.x0, constraint.y0, constraint.x0, constraint.y1);
94
+ }
95
+ //RIGHT
96
+ if (Number.isFinite(constraint.x1)) {
97
+ lines.push(constraint.x1, constraint.y0, constraint.x1, constraint.y1);
98
+ }
99
+
100
+ if (lines.length === 0) {
101
+ //no lines produced
102
+ return;
103
+ }
104
+ }
105
+
106
+ triggerSet.elements.forEach(processTrigger);
107
+
108
+ const builder = buildThreeJSHelperEntity(group);
109
+
110
+ api.emit(builder);
111
+ }
112
+
113
+ return make3DSymbolicDisplay({ engine, components: [StoryTriggerSet], factory });
114
+ }
@@ -0,0 +1,50 @@
1
+ import { SignalBinding } from "../../../src/core/events/signal/SignalBinding.js";
2
+
3
+ /**
4
+ *
5
+ * @param {!Transform} source
6
+ * @param {!Transform} target
7
+ * @param {SignalBinding[]} bindings
8
+ * @param {boolean} [syncPosition=true]
9
+ * @param {boolean} [syncRotation=true]
10
+ * @param {boolean} [syncScale=true]
11
+ */
12
+ export function synchronizeTransform(source, target, bindings, syncPosition = true, syncRotation = true, syncScale = true) {
13
+ function synchronizePosition(x, y, z) {
14
+ target.position.set(x, y, z);
15
+ }
16
+
17
+ function synchronizeScale(x, y, z) {
18
+ target.scale.set(x, y, z);
19
+ }
20
+
21
+ function synchronizeRotation(x, y, z, w) {
22
+ target.rotation.set(x, y, z, w);
23
+ }
24
+
25
+
26
+ if (syncPosition) {
27
+ const position = source.position;
28
+
29
+ bindings.push(new SignalBinding(position.onChanged, synchronizePosition));
30
+
31
+ synchronizePosition(position.x, position.y, position.z);
32
+ }
33
+
34
+ if (syncRotation) {
35
+ const rotation = source.rotation;
36
+
37
+ bindings.push(new SignalBinding(rotation.onChanged, synchronizeRotation));
38
+
39
+ synchronizeRotation(rotation.x, rotation.y, rotation.z, rotation.w);
40
+ }
41
+
42
+
43
+ if (syncScale) {
44
+ const scale = source.scale;
45
+ bindings.push(new SignalBinding(scale.onChanged, synchronizeScale));
46
+
47
+ synchronizePosition(scale.x, scale.y, scale.z);
48
+ }
49
+
50
+ }