@woosh/meep-engine 2.31.1 → 2.31.5

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 (55) hide show
  1. package/core/binary/BitSet.js +5 -1
  2. package/core/collection/RingBuffer.js +16 -1
  3. package/core/geom/Vector1.js +228 -219
  4. package/core/geom/Vector2.js +547 -502
  5. package/core/geom/Vector3.js +8 -0
  6. package/core/geom/Vector4.js +322 -311
  7. package/core/graph/v2/Graph.js +6 -6
  8. package/core/model/ObservedBoolean.js +12 -4
  9. package/core/process/worker/WorkerBuilder.js +27 -9
  10. package/core/process/worker/WorkerProxy.js +6 -0
  11. package/editor/Editor.js +10 -1
  12. package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +3 -1
  13. package/engine/EngineHarness.js +1 -1
  14. package/engine/ecs/parent/ParentEntitySystem.js +1 -1
  15. package/engine/ecs/terrain/ecs/Terrain.js +11 -2
  16. package/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +10 -10
  17. package/engine/graphics/camera/makeOrbitalCameraController.js +7 -1
  18. package/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +4 -31
  19. package/engine/graphics/ecs/mesh/Mesh.js +9 -3
  20. package/engine/graphics/ecs/path/entity/EntityPath.js +7 -7
  21. package/engine/graphics/ecs/trail2d/Trail2DSystem.js +31 -16
  22. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +17 -8
  23. package/engine/graphics/micron/build/graph/metis/metis.js +23 -33
  24. package/engine/graphics/micron/render/v1/MaterialContext.js +21 -2
  25. package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +1 -1
  26. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +1 -1
  27. package/engine/graphics/render/buffer/buffers/NormalFrameBuffer.js +25 -16
  28. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +6 -5
  29. package/engine/graphics/trail/x/RibbonMaterialX.js +7 -2
  30. package/engine/grid/components/GridPosition.js +22 -122
  31. package/engine/grid/components/GridPositionSerializationAdapter.js +58 -0
  32. package/engine/grid/components/GridPositionSerializationUpdater_0_1.js +37 -0
  33. package/engine/intelligence/mcts/MonteCarlo.js +12 -15
  34. package/engine/intelligence/mcts/StateNode.js +3 -3
  35. package/generation/GridTags.js +3 -2
  36. package/generation/example/SampleGenerator0.js +1 -1
  37. package/generation/example/generators/{mir_generator_place_buff_objects.js → interactive/mir_generator_place_buff_objects.js} +97 -26
  38. package/generation/example/generators/mir_generator_place_starting_point.js +12 -5
  39. package/generation/example/grid/configureMirGrid.js +1 -1
  40. package/generation/filtering/CellFilter.js +14 -0
  41. package/generation/filtering/numeric/util/CellFilterLogToConsole.js +2 -1
  42. package/generation/grid/GridData.js +18 -14
  43. package/generation/grid/MarkerMatchCounter.js +23 -0
  44. package/generation/grid/generation/GridTaskApplyActionToCells.js +86 -0
  45. package/generation/grid/generation/grid/select/CellSupplier.js +28 -0
  46. package/generation/grid/generation/grid/select/CellSupplierBestN.js +188 -0
  47. package/generation/grid/generation/grid/select/CellSupplierPathUpHill.js +187 -0
  48. package/generation/markers/GridActionRuleSet.js +1 -1
  49. package/generation/markers/MarkerNode.js +18 -0
  50. package/generation/markers/debug/visualizeMarkers.js +8 -1
  51. package/generation/markers/transform/MarkerNodeTransformerSequence.js +47 -0
  52. package/generation/placement/GridCellActionTransformNearbyMarkers.js +9 -17
  53. package/generation/rules/CellMatcherFromFilter.js +38 -0
  54. package/generation/rules/cell/CellMatcherContainsMarkerWithinRadius.js +1 -1
  55. package/package.json +3 -3
@@ -833,6 +833,14 @@ class Vector3 {
833
833
  return hash;
834
834
  }
835
835
 
836
+ *[ Symbol.iterator ]() {
837
+
838
+ yield this.x;
839
+ yield this.y;
840
+ yield this.z;
841
+
842
+ }
843
+
836
844
  /**
837
845
  * Dot product
838
846
  * @param {Vector3|Vector4} a
@@ -94,350 +94,361 @@ export function v4_distance_sqr(x0, y0, z0, w0, x1, y1, z1, w1) {
94
94
  return v4_length_sqr(x0 - x1, y0 - y1, z0 - z1, w0 - w1);
95
95
  }
96
96
 
97
- /**
98
- *
99
- * @param {Number} [x=0]
100
- * @param {Number} [y=0]
101
- * @param {Number} [z=0]
102
- * @param {Number} [w=0]
103
- * @constructor
104
- * @class
105
- */
106
- function Vector4(x, y, z, w) {
107
- this.x = (typeof x === "number") ? x : 0;
108
- this.y = (typeof x === "number") ? y : 0;
109
- this.z = (typeof z === "number") ? z : 0;
110
- this.w = (typeof w === "number") ? w : 1;
111
-
112
- this.onChanged = new Signal();
113
- }
97
+ class Vector4 {
98
+ /**
99
+ *
100
+ * @param {Number} [x=0]
101
+ * @param {Number} [y=0]
102
+ * @param {Number} [z=0]
103
+ * @param {Number} [w=0]
104
+ * @constructor
105
+ * @class
106
+ */
107
+ constructor(x, y, z, w) {
108
+ this.x = (typeof x === "number") ? x : 0;
109
+ this.y = (typeof x === "number") ? y : 0;
110
+ this.z = (typeof z === "number") ? z : 0;
111
+ this.w = (typeof w === "number") ? w : 1;
112
+
113
+ this.onChanged = new Signal();
114
+ }
114
115
 
115
- /**
116
- *
117
- * @param {number[]} array
118
- * @param {number} offset
119
- */
120
- Vector4.prototype.readFromArray = function (array, offset) {
121
- this.set(
122
- array[offset],
123
- array[offset + 1],
124
- array[offset + 2],
125
- array[offset + 3]
126
- );
127
- };
116
+ /**
117
+ *
118
+ * @param {number[]} array
119
+ * @param {number} offset
120
+ */
121
+ readFromArray(array, offset) {
122
+ this.set(
123
+ array[offset],
124
+ array[offset + 1],
125
+ array[offset + 2],
126
+ array[offset + 3]
127
+ );
128
+ }
128
129
 
129
- /**
130
- *
131
- * @param {number[]} array
132
- * @param {number} offset
133
- */
134
- Vector4.prototype.writeToArray = function (array, offset) {
135
- array[offset] = this.x;
136
- array[offset + 1] = this.y;
137
- array[offset + 2] = this.z;
138
- array[offset + 3] = this.w;
139
- };
130
+ /**
131
+ *
132
+ * @param {number[]} array
133
+ * @param {number} offset
134
+ */
135
+ writeToArray(array, offset) {
136
+ array[offset] = this.x;
137
+ array[offset + 1] = this.y;
138
+ array[offset + 2] = this.z;
139
+ array[offset + 3] = this.w;
140
+ }
140
141
 
141
- /**
142
- *
143
- * @param {Number} x
144
- * @param {Number} y
145
- * @param {Number} z
146
- * @param {Number} w
147
- * @returns {Vector4}
148
- */
149
- Vector4.prototype.set = function (x, y, z, w) {
150
- assert.equal(typeof x, "number", `X must be of type "number", instead was "${typeof x}"`);
151
- assert.equal(typeof y, "number", `Y must be of type "number", instead was "${typeof y}"`);
152
- assert.equal(typeof z, "number", `Z must be of type "number", instead was "${typeof z}"`);
153
- assert.equal(typeof w, "number", `W must be of type "number", instead was "${typeof w}"`);
154
-
155
- assert.ok(!Number.isNaN(x), `X must be a valid number, instead was NaN`);
156
- assert.ok(!Number.isNaN(y), `Y must be a valid number, instead was NaN`);
157
- assert.ok(!Number.isNaN(z), `Z must be a valid number, instead was NaN`);
158
- assert.ok(!Number.isNaN(w), `W must be a valid number, instead was NaN`);
159
-
160
- const _x = this.x;
161
- const _y = this.y;
162
- const _z = this.z;
163
- const _w = this.w;
164
-
165
- if (_x !== x || _y !== y || _z !== z || _w !== w) {
166
-
167
- this.x = x;
168
- this.y = y;
169
- this.z = z;
170
- this.w = w;
171
-
172
- if (this.onChanged.hasHandlers()) {
173
- this.onChanged.dispatch(x, y, z, w, _x, _y, _z, _w);
142
+ /**
143
+ *
144
+ * @param {Number} x
145
+ * @param {Number} y
146
+ * @param {Number} z
147
+ * @param {Number} w
148
+ * @returns {Vector4}
149
+ */
150
+ set(x, y, z, w) {
151
+ assert.equal(typeof x, "number", `X must be of type "number", instead was "${typeof x}"`);
152
+ assert.equal(typeof y, "number", `Y must be of type "number", instead was "${typeof y}"`);
153
+ assert.equal(typeof z, "number", `Z must be of type "number", instead was "${typeof z}"`);
154
+ assert.equal(typeof w, "number", `W must be of type "number", instead was "${typeof w}"`);
155
+
156
+ assert.ok(!Number.isNaN(x), `X must be a valid number, instead was NaN`);
157
+ assert.ok(!Number.isNaN(y), `Y must be a valid number, instead was NaN`);
158
+ assert.ok(!Number.isNaN(z), `Z must be a valid number, instead was NaN`);
159
+ assert.ok(!Number.isNaN(w), `W must be a valid number, instead was NaN`);
160
+
161
+ const _x = this.x;
162
+ const _y = this.y;
163
+ const _z = this.z;
164
+ const _w = this.w;
165
+
166
+ if (_x !== x || _y !== y || _z !== z || _w !== w) {
167
+
168
+ this.x = x;
169
+ this.y = y;
170
+ this.z = z;
171
+ this.w = w;
172
+
173
+ if (this.onChanged.hasHandlers()) {
174
+ this.onChanged.dispatch(x, y, z, w, _x, _y, _z, _w);
175
+ }
174
176
  }
177
+
178
+ return this;
175
179
  }
176
180
 
177
- return this;
178
- };
181
+ /**
182
+ *
183
+ * @param {Vector3} v3
184
+ */
185
+ multiplyVector3(v3) {
186
+ const x = this.x * v3.x;
187
+ const y = this.y * v3.y;
188
+ const z = this.z * v3.z;
179
189
 
180
- /**
181
- *
182
- * @param {Vector3} v3
183
- */
184
- Vector4.prototype.multiplyVector3 = function (v3) {
185
- const x = this.x * v3.x;
186
- const y = this.y * v3.y;
187
- const z = this.z * v3.z;
190
+ this.set(x, y, z, this.w);
191
+ }
188
192
 
189
- this.set(x, y, z, this.w);
190
- };
193
+ /**
194
+ *
195
+ * @param {Number} value
196
+ * @returns {Vector4}
197
+ */
198
+ multiplyScalar(value) {
199
+ assert.equal(typeof value, "number", `Input scalar must be of type "number", instead was "${typeof value}"`);
200
+ assert.ok(!Number.isNaN(value), `Input scalar must be a valid number, instead was NaN`);
191
201
 
192
- /**
193
- *
194
- * @param {Number} value
195
- * @returns {Vector4}
196
- */
197
- Vector4.prototype.multiplyScalar = function (value) {
198
- assert.equal(typeof value, "number", `Input scalar must be of type "number", instead was "${typeof value}"`);
199
- assert.ok(!Number.isNaN(value), `Input scalar must be a valid number, instead was NaN`);
202
+ return this.set(this.x * value, this.y * value, this.z * value, this.w * value);
203
+ }
200
204
 
201
- return this.set(this.x * value, this.y * value, this.z * value, this.w * value);
202
- };
205
+ /**
206
+ *
207
+ * @param {number} a0
208
+ * @param {number} a1
209
+ * @param {number} a2
210
+ * @param {number} a3
211
+ * @param {number} b0
212
+ * @param {number} b1
213
+ * @param {number} b2
214
+ * @param {number} b3
215
+ * @param {number} c0
216
+ * @param {number} c1
217
+ * @param {number} c2
218
+ * @param {number} c3
219
+ * @param {number} d0
220
+ * @param {number} d1
221
+ * @param {number} d2
222
+ * @param {number} d3
223
+ * @returns {Vector4} this
224
+ */
225
+ _applyMatrix4(
226
+ a0, a1, a2, a3,
227
+ b0, b1, b2, b3,
228
+ c0, c1, c2, c3,
229
+ d0, d1, d2, d3
230
+ ) {
231
+
232
+ const _x = this.x;
233
+ const _y = this.y;
234
+ const _z = this.z;
235
+ const _w = this.w;
236
+
237
+ const x = a0 * _x + b0 * _y + c0 * _z + d0 * _w;
238
+ const y = a1 * _x + b1 * _y + c1 * _z + d1 * _w;
239
+ const z = a2 * _x + b2 * _y + c2 * _z + d2 * _w;
240
+ const w = a3 * _x + b3 * _y + c3 * _z + d3 * _w;
241
+
242
+ return this.set(x, y, z, w);
243
+ }
203
244
 
204
- /**
205
- *
206
- * @param {number} a0
207
- * @param {number} a1
208
- * @param {number} a2
209
- * @param {number} a3
210
- * @param {number} b0
211
- * @param {number} b1
212
- * @param {number} b2
213
- * @param {number} b3
214
- * @param {number} c0
215
- * @param {number} c1
216
- * @param {number} c2
217
- * @param {number} c3
218
- * @param {number} d0
219
- * @param {number} d1
220
- * @param {number} d2
221
- * @param {number} d3
222
- * @returns {Vector4} this
223
- */
224
- Vector4.prototype._applyMatrix4 = function (
225
- a0, a1, a2, a3,
226
- b0, b1, b2, b3,
227
- c0, c1, c2, c3,
228
- d0, d1, d2, d3
229
- ) {
230
-
231
- const _x = this.x;
232
- const _y = this.y;
233
- const _z = this.z;
234
- const _w = this.w;
245
+ /**
246
+ *
247
+ * @param {Vector4} other
248
+ * @returns {number}
249
+ */
250
+ dot(other) {
251
+ return this.x * other.x + this.y * other.y + this.z * other.z + this.w * other.w;
252
+ }
235
253
 
236
- const x = a0 * _x + b0 * _y + c0 * _z + d0 * _w;
237
- const y = a1 * _x + b1 * _y + c1 * _z + d1 * _w;
238
- const z = a2 * _x + b2 * _y + c2 * _z + d2 * _w;
239
- const w = a3 * _x + b3 * _y + c3 * _z + d3 * _w;
254
+ /**
255
+ * Add XYZ components from another vector
256
+ * @param {Vector3|Vector4} v3
257
+ * @returns {Vector4}
258
+ */
259
+ add3(v3) {
260
+ return this.set(this.x + v3.x, this.y + v3.y, this.z + v3.z, this.w);
261
+ }
240
262
 
241
- return this.set(x, y, z, w);
242
- };
263
+ /**
264
+ *
265
+ * @param {Matrix4} m
266
+ * @returns {Vector4} this
267
+ */
268
+ threeApplyMatrix4(m) {
269
+ const e = m.elements;
270
+ return this._applyMatrix4(
271
+ e[0], e[1], e[2], e[3],
272
+ e[4], e[5], e[6], e[7],
273
+ e[8], e[9], e[10], e[11],
274
+ e[12], e[13], e[14], e[15]
275
+ );
276
+ }
243
277
 
244
- /**
245
- *
246
- * @param {Vector4} other
247
- * @returns {number}
248
- */
249
- Vector4.prototype.dot = function (other) {
250
- return this.x * other.x + this.y * other.y + this.z * other.z + this.w * other.w;
251
- };
278
+ /**
279
+ *
280
+ * @param {Vector4} vec4
281
+ * @returns {Vector4}
282
+ */
283
+ copy(vec4) {
284
+ return this.set(vec4.x, vec4.y, vec4.z, vec4.w);
285
+ }
252
286
 
253
- /**
254
- * Add XYZ components from another vector
255
- * @param {Vector3|Vector4} v3
256
- * @returns {Vector4}
257
- */
258
- Vector4.prototype.add3 = function (v3) {
259
- return this.set(this.x + v3.x, this.y + v3.y, this.z + v3.z, this.w);
260
- };
287
+ /**
288
+ *
289
+ * @returns {Vector4}
290
+ */
291
+ clone() {
292
+ const r = new Vector4();
261
293
 
262
- /**
263
- *
264
- * @param {Matrix4} m
265
- * @returns {Vector4} this
266
- */
267
- Vector4.prototype.threeApplyMatrix4 = function (m) {
268
- const e = m.elements;
269
- return this._applyMatrix4(
270
- e[0], e[1], e[2], e[3],
271
- e[4], e[5], e[6], e[7],
272
- e[8], e[9], e[10], e[11],
273
- e[12], e[13], e[14], e[15]
274
- );
275
- };
294
+ r.copy(this);
276
295
 
277
- /**
278
- *
279
- * @param {Vector4} vec4
280
- * @returns {Vector4}
281
- */
282
- Vector4.prototype.copy = function (vec4) {
283
- return this.set(vec4.x, vec4.y, vec4.z, vec4.w);
284
- };
296
+ return r;
297
+ }
285
298
 
286
- /**
287
- *
288
- * @returns {Vector4}
289
- */
290
- Vector4.prototype.clone = function () {
291
- const r = new Vector4();
299
+ /**
300
+ *
301
+ * @param {Quaternion} q
302
+ */
303
+ applyQuaternion(q) {
304
+ const x = this.x;
305
+ const y = this.y;
306
+ const z = this.z;
307
+ const w = this.w;
308
+
309
+ const qx = q.x;
310
+ const qy = q.y;
311
+ const qz = q.z;
312
+ const qw = q.w;
313
+
314
+ // calculate quat * vec
315
+ let ix = qw * x + qy * z - qz * y;
316
+ let iy = qw * y + qz * x - qx * z;
317
+ let iz = qw * z + qx * y - qy * x;
318
+ let iw = -qx * x - qy * y - qz * z;
319
+
320
+ // calculate result * inverse quat
321
+ const _x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
322
+ const _y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
323
+ const _z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
324
+
325
+ this.set(_x, _y, _z, w);
326
+ }
292
327
 
293
- r.copy(this);
328
+ /**
329
+ *
330
+ * @param {Vector4} vec4
331
+ * @returns {boolean}
332
+ */
333
+ equals(vec4) {
334
+ return this.x === vec4.x && this.y === vec4.y && this.z === vec4.z && this.w === vec4.w;
335
+ }
294
336
 
295
- return r;
296
- };
337
+ /**
338
+ *
339
+ * @return {number}
340
+ */
341
+ hash() {
342
+ return computeHashIntegerArray(
343
+ computeHashFloat(this.x),
344
+ computeHashFloat(this.y),
345
+ computeHashFloat(this.z),
346
+ computeHashFloat(this.w)
347
+ );
348
+ }
297
349
 
298
- /**
299
- *
300
- * @param {Quaternion} q
301
- */
302
- Vector4.prototype.applyQuaternion = function (q) {
303
- const x = this.x;
304
- const y = this.y;
305
- const z = this.z;
306
- const w = this.w;
307
-
308
- const qx = q.x;
309
- const qy = q.y;
310
- const qz = q.z;
311
- const qw = q.w;
312
-
313
- // calculate quat * vec
314
- let ix = qw * x + qy * z - qz * y;
315
- let iy = qw * y + qz * x - qx * z;
316
- let iz = qw * z + qx * y - qy * x;
317
- let iw = -qx * x - qy * y - qz * z;
318
-
319
- // calculate result * inverse quat
320
- const _x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
321
- const _y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
322
- const _z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
323
-
324
- this.set(_x, _y, _z, w);
325
- };
350
+ /**
351
+ * @param {Vector4} v0
352
+ * @param {Vector4} v1
353
+ * @param {Number} f interpolation fraction
354
+ */
355
+ lerpVectors(v0, v1, f) {
356
+ Vector4.lerp(v0, v1, f, this);
357
+ }
326
358
 
327
- /**
328
- *
329
- * @param {Vector4} vec4
330
- * @returns {boolean}
331
- */
332
- Vector4.prototype.equals = function (vec4) {
333
- return this.x === vec4.x && this.y === vec4.y && this.z === vec4.z && this.w === vec4.w;
334
- };
359
+ /**
360
+ *
361
+ * @param {number[]} result
362
+ */
363
+ toArray(result) {
364
+ result[0] = this.x;
365
+ result[1] = this.y;
366
+ result[2] = this.z;
367
+ result[3] = this.w;
368
+ }
335
369
 
336
- /**
337
- *
338
- * @return {number}
339
- */
340
- Vector4.prototype.hash = function () {
341
- return computeHashIntegerArray(
342
- computeHashFloat(this.x),
343
- computeHashFloat(this.y),
344
- computeHashFloat(this.z),
345
- computeHashFloat(this.w)
346
- );
347
- };
370
+ /**
371
+ * @returns {number[]}
372
+ */
373
+ asArray() {
374
+ const result = [];
348
375
 
376
+ this.toArray(result);
349
377
 
350
- /**
351
- * @param {Vector4} v0
352
- * @param {Vector4} v1
353
- * @param {Number} f interpolation fraction
354
- */
355
- Vector4.prototype.lerpVectors = function (v0, v1, f) {
356
- Vector4.lerp(v0, v1, f, this);
357
- };
378
+ return result;
379
+ }
358
380
 
359
- /**
360
- *
361
- * @param {Vector4} v0
362
- * @param {Vector4} v1
363
- * @param {Number} f interpolation fraction
364
- * @param {Vector4} result
365
- */
366
- Vector4.lerp = function (v0, v1, f, result) {
367
- const x = lerp(v0.x, v1.x, f);
368
- const y = lerp(v0.y, v1.y, f);
369
- const z = lerp(v0.z, v1.z, f);
370
- const w = lerp(v0.w, v1.w, f);
381
+ /**
382
+ *
383
+ * @param {number[]} data
384
+ * @param {number} offset
385
+ */
386
+ setFromArray(data, offset) {
387
+ this.set(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]);
388
+ }
371
389
 
372
- result.set(x, y, z, w);
373
- };
390
+ toJSON() {
391
+ return {
392
+ x: this.x,
393
+ y: this.y,
394
+ z: this.z,
395
+ w: this.w
396
+ };
397
+ }
374
398
 
399
+ fromJSON(json) {
400
+ this.copy(json);
401
+ }
375
402
 
376
- /**
377
- *
378
- * @param {number[]} result
379
- */
380
- Vector4.prototype.toArray = function (result) {
381
- result[0] = this.x;
382
- result[1] = this.y;
383
- result[2] = this.z;
384
- result[3] = this.w;
385
- };
403
+ /**
404
+ *
405
+ * @param {BinaryBuffer} buffer
406
+ */
407
+ toBinaryBuffer(buffer) {
408
+ buffer.writeFloat64(this.x);
409
+ buffer.writeFloat64(this.y);
410
+ buffer.writeFloat64(this.z);
411
+ buffer.writeFloat64(this.w);
412
+ }
386
413
 
387
- /**
388
- * @returns {number[]}
389
- */
390
- Vector4.prototype.asArray = function () {
391
- const result = [];
414
+ /**
415
+ *
416
+ * @param {BinaryBuffer} buffer
417
+ */
418
+ fromBinaryBuffer(buffer) {
419
+ const x = buffer.readFloat64();
420
+ const y = buffer.readFloat64();
421
+ const z = buffer.readFloat64();
422
+ const w = buffer.readFloat64();
423
+
424
+ this.set(x, y, z, w);
425
+ }
392
426
 
393
- this.toArray(result);
427
+ *[ Symbol.iterator ]() {
394
428
 
395
- return result;
396
- };
429
+ yield this.x;
430
+ yield this.y;
431
+ yield this.z;
432
+ yield this.w;
397
433
 
398
- /**
399
- *
400
- * @param {number[]} data
401
- * @param {number} offset
402
- */
403
- Vector4.prototype.setFromArray = function (data, offset) {
404
- this.set(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]);
405
- };
406
-
407
- Vector4.prototype.toJSON = function () {
408
- return {
409
- x: this.x,
410
- y: this.y,
411
- z: this.z,
412
- w: this.w
413
- };
414
- };
415
-
416
- Vector4.prototype.fromJSON = function (json) {
417
- this.copy(json);
418
- };
434
+ }
435
+
436
+ /**
437
+ *
438
+ * @param {Vector4} v0
439
+ * @param {Vector4} v1
440
+ * @param {Number} f interpolation fraction
441
+ * @param {Vector4} result
442
+ */
443
+ static lerp(v0, v1, f, result) {
444
+ const x = lerp(v0.x, v1.x, f);
445
+ const y = lerp(v0.y, v1.y, f);
446
+ const z = lerp(v0.z, v1.z, f);
447
+ const w = lerp(v0.w, v1.w, f);
448
+
449
+ result.set(x, y, z, w);
450
+ }
451
+ }
419
452
 
420
- /**
421
- *
422
- * @param {BinaryBuffer} buffer
423
- */
424
- Vector4.prototype.toBinaryBuffer = function (buffer) {
425
- buffer.writeFloat64(this.x);
426
- buffer.writeFloat64(this.y);
427
- buffer.writeFloat64(this.z);
428
- buffer.writeFloat64(this.w);
429
- };
430
453
 
431
- /**
432
- *
433
- * @param {BinaryBuffer} buffer
434
- */
435
- Vector4.prototype.fromBinaryBuffer = function (buffer) {
436
- const x = buffer.readFloat64();
437
- const y = buffer.readFloat64();
438
- const z = buffer.readFloat64();
439
- const w = buffer.readFloat64();
440
-
441
- this.set(x, y, z, w);
442
- };
443
454
  export default Vector4;