@woosh/meep-engine 2.33.72 → 2.33.73

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.
@@ -8,10 +8,11 @@ import { assert } from "../../../../../core/assert.js";
8
8
  import { lerp } from "../../../../../core/math/lerp.js";
9
9
  import { Euler, Matrix4 } from "three";
10
10
  import { normalize_angle_rad } from "../../../../../core/geom/normalize_angle_rad.js";
11
- import { v3_angle_between_atan2 } from "../../../../../core/geom/v3_angle_between.js";
11
+ import { eulerAnglesFromMatrix } from "../../../../../core/geom/3d/eulerAnglesFromMatrix.js";
12
12
 
13
13
  const m4 = new Matrix4();
14
14
  const euler = new Euler();
15
+ const angles = [];
15
16
 
16
17
  const panOffset = new Vector3();
17
18
 
@@ -123,56 +124,6 @@ class TopDownCameraController {
123
124
  * @param {Vector3} [up]
124
125
  */
125
126
  setFromEyeAndTarget(eye, target, up = Vector3.up) {
126
- /**
127
- * ----
128
- * float projectOnPlane(Vector3 a, Vector3 b) {
129
- * Vector3 bProjection = (Vector3.Dot(a, b) / b.Length) * (b / b.Length);
130
- * return a - bProjection;
131
- * }
132
- * ----
133
- * @see https://gamedev.stackexchange.com/questions/134354/gravity-vector-and-forward-vector-to-local-heading-yaw-pitch-and-roll
134
- * @param {Vector3} a
135
- * @param {Vector3} b
136
- */
137
- function projectOnPlane(a, b) {
138
- const i = a.dot(b) / b.length();
139
- const j = new Vector3();
140
- j.copy(b);
141
- j.normalize();
142
-
143
- j.multiplyScalar(i);
144
-
145
- j.subVectors(a, j);
146
-
147
- return j;
148
- }
149
-
150
- function pitch(direction, gravity) {
151
- const heading = projectOnPlane(direction, gravity);
152
-
153
- return v3_angle_between_atan2(
154
- direction.x, direction.y, direction.z,
155
- heading.x, heading.y, heading.z
156
- )
157
- }
158
-
159
- function yaw(direction, gravity, north) {
160
- const heading = projectOnPlane(direction, gravity);
161
-
162
- return v3_angle_between_atan2(
163
- heading.x, heading.y, heading.z,
164
- north.x, north.y, north.z,
165
- );
166
- }
167
-
168
-
169
- // extract pitch and yaw only
170
- const view_vector = new Vector3();
171
- view_vector.subVectors(eye, target);
172
-
173
-
174
- const _p3 = pitch(view_vector, up);
175
- const _y3 = yaw(view_vector, up, Vector3.back);
176
127
 
177
128
  /*
178
129
  NOTE: I'm not sure why, but three.js camera points in the opposite direction to normal objects
@@ -180,17 +131,11 @@ class TopDownCameraController {
180
131
  */
181
132
  m4.lookAt(target, eye, up);
182
133
 
134
+ eulerAnglesFromMatrix(angles, m4.elements, 2, 1, 0)
183
135
 
184
- euler.setFromRotationMatrix(m4, 'ZYX');
185
-
186
-
187
- const _p0 = normalize_angle_rad(euler.x);
188
- const _y0 = normalize_angle_rad(euler.y);
189
- const _r0 = normalize_angle_rad(euler.z);
190
-
191
- this.pitch = _p3;
192
- this.yaw = _y3;
193
- this.roll = 0;
136
+ this.pitch = angles[2];
137
+ this.yaw = angles[1];
138
+ this.roll = angles[0];
194
139
 
195
140
  this.distance = eye.distanceTo(target);
196
141
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.33.72",
8
+ "version": "2.33.73",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",