@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.
- package/core/binary/BitSet.js +5 -1
- package/core/collection/RingBuffer.js +16 -1
- package/core/geom/Vector1.js +228 -219
- package/core/geom/Vector2.js +547 -502
- package/core/geom/Vector3.js +8 -0
- package/core/geom/Vector4.js +322 -311
- package/core/graph/v2/Graph.js +6 -6
- package/core/model/ObservedBoolean.js +12 -4
- package/core/process/worker/WorkerBuilder.js +27 -9
- package/core/process/worker/WorkerProxy.js +6 -0
- package/editor/Editor.js +10 -1
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +3 -1
- package/engine/EngineHarness.js +1 -1
- package/engine/ecs/parent/ParentEntitySystem.js +1 -1
- package/engine/ecs/terrain/ecs/Terrain.js +11 -2
- package/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +10 -10
- package/engine/graphics/camera/makeOrbitalCameraController.js +7 -1
- package/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +4 -31
- package/engine/graphics/ecs/mesh/Mesh.js +9 -3
- package/engine/graphics/ecs/path/entity/EntityPath.js +7 -7
- package/engine/graphics/ecs/trail2d/Trail2DSystem.js +31 -16
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +17 -8
- package/engine/graphics/micron/build/graph/metis/metis.js +23 -33
- package/engine/graphics/micron/render/v1/MaterialContext.js +21 -2
- package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +1 -1
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +1 -1
- package/engine/graphics/render/buffer/buffers/NormalFrameBuffer.js +25 -16
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +6 -5
- package/engine/graphics/trail/x/RibbonMaterialX.js +7 -2
- package/engine/grid/components/GridPosition.js +22 -122
- package/engine/grid/components/GridPositionSerializationAdapter.js +58 -0
- package/engine/grid/components/GridPositionSerializationUpdater_0_1.js +37 -0
- package/engine/intelligence/mcts/MonteCarlo.js +12 -15
- package/engine/intelligence/mcts/StateNode.js +3 -3
- package/generation/GridTags.js +3 -2
- package/generation/example/SampleGenerator0.js +1 -1
- package/generation/example/generators/{mir_generator_place_buff_objects.js → interactive/mir_generator_place_buff_objects.js} +97 -26
- package/generation/example/generators/mir_generator_place_starting_point.js +12 -5
- package/generation/example/grid/configureMirGrid.js +1 -1
- package/generation/filtering/CellFilter.js +14 -0
- package/generation/filtering/numeric/util/CellFilterLogToConsole.js +2 -1
- package/generation/grid/GridData.js +18 -14
- package/generation/grid/MarkerMatchCounter.js +23 -0
- package/generation/grid/generation/GridTaskApplyActionToCells.js +86 -0
- package/generation/grid/generation/grid/select/CellSupplier.js +28 -0
- package/generation/grid/generation/grid/select/CellSupplierBestN.js +188 -0
- package/generation/grid/generation/grid/select/CellSupplierPathUpHill.js +187 -0
- package/generation/markers/GridActionRuleSet.js +1 -1
- package/generation/markers/MarkerNode.js +18 -0
- package/generation/markers/debug/visualizeMarkers.js +8 -1
- package/generation/markers/transform/MarkerNodeTransformerSequence.js +47 -0
- package/generation/placement/GridCellActionTransformNearbyMarkers.js +9 -17
- package/generation/rules/CellMatcherFromFilter.js +38 -0
- package/generation/rules/cell/CellMatcherContainsMarkerWithinRadius.js +1 -1
- package/package.json +3 -3
package/core/geom/Vector3.js
CHANGED
package/core/geom/Vector4.js
CHANGED
|
@@ -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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*
|
|
211
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
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
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
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
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
427
|
+
*[ Symbol.iterator ]() {
|
|
394
428
|
|
|
395
|
-
|
|
396
|
-
|
|
429
|
+
yield this.x;
|
|
430
|
+
yield this.y;
|
|
431
|
+
yield this.z;
|
|
432
|
+
yield this.w;
|
|
397
433
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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;
|