@woosh/meep-engine 3.0.0 → 3.0.1
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/particles/rebuildParticleEmitter.js +8 -26
- package/editor/process/symbolic/CameraSymbolicDisplay.js +146 -146
- package/editor/tools/SelectionTool.js +1 -2
- package/editor/tools/TransformToolV2.js +2 -3
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +501 -501
- package/editor/tools/v2/TransformControls.js +1 -1
- package/package.json +95 -96
- package/src/core/geom/3d/mat4/m4_look_at.d.ts +25 -0
- package/src/core/geom/3d/mat4/m4_look_at.d.ts.map +1 -0
- package/src/core/geom/3d/mat4/m4_look_at.js +96 -0
- package/src/core/geom/3d/mat4/m4_make_rotation_x.d.ts +18 -0
- package/src/core/geom/3d/mat4/m4_make_rotation_x.d.ts.map +1 -0
- package/src/core/geom/3d/mat4/m4_make_rotation_x.js +47 -0
- package/src/core/geom/3d/mat4/m4_make_rotation_y.d.ts +18 -0
- package/src/core/geom/3d/mat4/m4_make_rotation_y.d.ts.map +1 -0
- package/src/core/geom/3d/mat4/m4_make_rotation_y.js +47 -0
- package/src/core/geom/3d/mat4/m4_make_rotation_z.d.ts +18 -0
- package/src/core/geom/3d/mat4/m4_make_rotation_z.d.ts.map +1 -0
- package/src/core/geom/3d/mat4/m4_make_rotation_z.js +47 -0
- package/src/core/geom/3d/mat4/m4_perspective.d.ts +25 -0
- package/src/core/geom/3d/mat4/m4_perspective.d.ts.map +1 -0
- package/src/core/geom/3d/mat4/m4_perspective.js +66 -0
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +2045 -2052
- package/src/engine/ecs/gui/hud/testHudEdgeStick.js +2 -2
- package/src/engine/ecs/terrain/ecs/TerrainSystem.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/TerrainSystem.js +14 -27
- package/src/engine/ecs/terrain/util/loadVisibleTerrainTiles.d.ts.map +1 -1
- package/src/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +129 -126
- package/src/engine/graphics/ecs/camera/Camera.d.ts +36 -48
- package/src/engine/graphics/ecs/camera/Camera.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/Camera.js +165 -303
- package/src/engine/graphics/ecs/camera/camera_active_frustum.d.ts +14 -0
- package/src/engine/graphics/ecs/camera/camera_active_frustum.d.ts.map +1 -0
- package/src/engine/graphics/ecs/camera/camera_active_frustum.js +25 -0
- package/src/engine/graphics/ecs/camera/camera_find_active.d.ts +16 -0
- package/src/engine/graphics/ecs/camera/camera_find_active.d.ts.map +1 -0
- package/src/engine/graphics/ecs/camera/camera_find_active.js +28 -0
- package/src/engine/graphics/ecs/camera/camera_traverse_active.d.ts +12 -0
- package/src/engine/graphics/ecs/camera/camera_traverse_active.d.ts.map +1 -0
- package/src/engine/graphics/ecs/camera/camera_traverse_active.js +18 -0
- package/src/engine/graphics/ecs/camera/pp/PerfectPanner.js +170 -170
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts +5 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +296 -281
- package/src/engine/graphics/ecs/render_layers_compute_depth_range.d.ts +1 -1
- package/src/engine/graphics/ecs/render_layers_compute_depth_range.js +1 -1
- package/src/engine/graphics/geometry/AttributeData.d.ts +52 -0
- package/src/engine/graphics/geometry/AttributeData.d.ts.map +1 -0
- package/src/engine/graphics/geometry/AttributeData.js +84 -0
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.d.ts +1 -14
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +229 -253
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts +25 -12
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1149 -1194
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.d.ts +4 -8
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +472 -540
- package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.d.ts +19 -90
- package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +135 -514
- package/src/engine/graphics3/CameraSystem3.d.ts.map +1 -1
- package/src/engine/graphics3/CameraSystem3.js +10 -1
- package/src/engine/graphics3/GraphicsEngine3.d.ts +3 -3
- package/src/engine/graphics3/GraphicsEngine3.js +3 -3
- package/src/engine/graphics3/ParticleEmitterSystem3.d.ts +11 -0
- package/src/engine/graphics3/ParticleEmitterSystem3.d.ts.map +1 -1
- package/src/engine/graphics3/ParticleEmitterSystem3.js +289 -265
- package/src/engine/graphics3/ShadeCameraAdapter.d.ts +3 -3
- package/src/engine/graphics3/ShadeCameraAdapter.js +3 -3
- package/src/engine/graphics3/camera_sync_from_transform.d.ts +2 -2
- package/src/engine/graphics3/camera_sync_from_transform.js +2 -2
- package/src/engine/graphics3/shade_camera_projection_ray.js +2 -2
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/renderer/camera/Camera.d.ts +3 -5
- package/src/shade/renderer/camera/Camera.d.ts.map +1 -1
- package/src/shade/renderer/camera/Camera.js +281 -280
- package/src/shade/renderer/camera/GPUCameraContext.js +233 -233
- package/src/shade/renderer/loader/usd/parse_usda.js +1 -1
- package/src/shade/renderer/loader/usd/usd_build_scene.d.ts.map +1 -1
- package/src/shade/renderer/loader/usd/usd_build_scene.js +658 -652
- package/src/shade/renderer/loader/usd/usd_compose_transform.d.ts.map +1 -1
- package/src/shade/renderer/loader/usd/usd_compose_transform.js +58 -23
- package/src/shade/renderer/particles/prototypeParticleSystem.js +450 -443
- package/src/shade/renderer/shadow/map/DirectionalLightShadowmap.d.ts.map +1 -1
- package/src/shade/renderer/shadow/map/DirectionalLightShadowmap.js +7 -3
- package/src/view/minimap/dom/MinimapCameraView.d.ts +2 -2
- package/src/view/minimap/dom/MinimapCameraView.js +206 -206
- package/src/engine/graphics/ecs/camera/CameraSystem.d.ts +0 -74
- package/src/engine/graphics/ecs/camera/CameraSystem.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/CameraSystem.js +0 -331
- package/src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.d.ts +0 -10
- package/src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.js +0 -105
- package/src/engine/graphics/ecs/camera/build_three_camera_object.d.ts +0 -7
- package/src/engine/graphics/ecs/camera/build_three_camera_object.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/build_three_camera_object.js +0 -29
- package/src/engine/graphics/ecs/camera/frustum_from_camera.d.ts +0 -8
- package/src/engine/graphics/ecs/camera/frustum_from_camera.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/frustum_from_camera.js +0 -20
- package/src/engine/graphics/ecs/camera/set_camera_aspect_ratio.d.ts +0 -9
- package/src/engine/graphics/ecs/camera/set_camera_aspect_ratio.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/set_camera_aspect_ratio.js +0 -46
- package/src/engine/graphics/ecs/camera/unprojectPoint.d.ts +0 -9
- package/src/engine/graphics/ecs/camera/unprojectPoint.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/unprojectPoint.js +0 -14
- package/src/engine/graphics/ecs/camera/update_camera_transform.d.ts +0 -6
- package/src/engine/graphics/ecs/camera/update_camera_transform.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/update_camera_transform.js +0 -17
- package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.d.ts +0 -67
- package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.d.ts.map +0 -1
- package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +0 -291
- package/src/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.d.ts +0 -11
- package/src/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.d.ts.map +0 -1
- package/src/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +0 -497
- package/src/engine/graphics/particles/particular/engine/shader/MaterialRecord.d.ts +0 -40
- package/src/engine/graphics/particles/particular/engine/shader/MaterialRecord.d.ts.map +0 -1
- package/src/engine/graphics/particles/particular/engine/shader/MaterialRecord.js +0 -47
- package/src/engine/graphics/texture/sampler/writeSampler2DDataToDataTexture.d.ts +0 -7
- package/src/engine/graphics/texture/sampler/writeSampler2DDataToDataTexture.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/writeSampler2DDataToDataTexture.js +0 -40
|
@@ -1,281 +1,296 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* @param {
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
target
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
183
|
-
*/
|
|
184
|
-
|
|
185
|
-
this.target.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
*
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
*
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
pitch
|
|
247
|
-
yaw
|
|
248
|
-
roll
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
1
|
+
import { assert } from "../../../../../core/assert.js";
|
|
2
|
+
import { m4_euler_angles } from "../../../../../core/geom/3d/mat4/m4_euler_angles.js";
|
|
3
|
+
import {
|
|
4
|
+
m4_from_rotation_translation_scale_scalar
|
|
5
|
+
} from "../../../../../core/geom/3d/mat4/m4_from_rotation_translation_scale_scalar.js";
|
|
6
|
+
import { normalize_angle_rad } from "../../../../../core/geom/normalize_angle_rad.js";
|
|
7
|
+
import Quaternion from "../../../../../core/geom/Quaternion.js";
|
|
8
|
+
import Vector3 from '../../../../../core/geom/Vector3.js';
|
|
9
|
+
import { lerp } from "../../../../../core/math/lerp.js";
|
|
10
|
+
import { max2 } from "../../../../../core/math/max2.js";
|
|
11
|
+
import { sign_not_zero } from "../../../../../core/math/sign_not_zero.js";
|
|
12
|
+
|
|
13
|
+
const m4 = [];
|
|
14
|
+
const angles = [];
|
|
15
|
+
|
|
16
|
+
const q_look = new Quaternion();
|
|
17
|
+
const v3_forward = new Vector3();
|
|
18
|
+
|
|
19
|
+
const q_view = new Quaternion();
|
|
20
|
+
|
|
21
|
+
const v3_view_right = new Vector3();
|
|
22
|
+
const v3_view_up = new Vector3();
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {number} displacement_x
|
|
28
|
+
* @param {number} displacement_y
|
|
29
|
+
* @param {TopDownCameraController} input source thing being rotated
|
|
30
|
+
* @param {TopDownCameraController} output target thing where the result is written to
|
|
31
|
+
*/
|
|
32
|
+
export function rotate_from_view(displacement_x, displacement_y, input, output) {
|
|
33
|
+
// crop yaw and pitch to safe range of -PI to PI
|
|
34
|
+
const i_pitch = normalize_angle_rad(input.pitch);
|
|
35
|
+
const i_yaw = normalize_angle_rad(input.yaw);
|
|
36
|
+
const i_roll = normalize_angle_rad(input.roll);
|
|
37
|
+
|
|
38
|
+
const quaternion = Quaternion.fromEulerAngles(i_pitch, i_yaw, i_roll);
|
|
39
|
+
const forward = Vector3.up.clone();
|
|
40
|
+
forward.applyQuaternion(quaternion);
|
|
41
|
+
|
|
42
|
+
// flip rotation axis when pitch is over 90deg in either direction, that is UP vector is pointing down
|
|
43
|
+
const d_yaw = sign_not_zero(forward.y) * displacement_x;
|
|
44
|
+
|
|
45
|
+
output.yaw = i_yaw + d_yaw;
|
|
46
|
+
output.pitch = i_pitch - displacement_y;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The orientation a controller looks along. The camera's transform is built from this and the
|
|
51
|
+
* distance, so anything that needs the view's own axes takes them from here rather than from
|
|
52
|
+
* whatever object a renderer happens to keep.
|
|
53
|
+
*
|
|
54
|
+
* @param {Quaternion} result
|
|
55
|
+
* @param {TopDownCameraController} controller
|
|
56
|
+
*/
|
|
57
|
+
export function top_down_view_rotation(result, controller) {
|
|
58
|
+
result.fromEulerAnglesZYX(controller.pitch, controller.yaw, controller.roll);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {Vector3} result
|
|
63
|
+
* @param {Vector3} direction unit length
|
|
64
|
+
* @param {number} distance world units
|
|
65
|
+
* @param {Vector3} multiplier
|
|
66
|
+
*/
|
|
67
|
+
function move_along(result, direction, distance, multiplier) {
|
|
68
|
+
result._add(
|
|
69
|
+
direction.x * distance * multiplier.x,
|
|
70
|
+
direction.y * distance * multiplier.y,
|
|
71
|
+
direction.z * distance * multiplier.z
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const deg2_in_rad = Math.PI / 360;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Move a controller's target across the view plane it is looking at, by a displacement given in
|
|
79
|
+
* viewport pixels; right and down are positive.
|
|
80
|
+
*
|
|
81
|
+
* Handlers pass where the pointer *was* less where it *is*, so the target travels against the drag
|
|
82
|
+
* and the world under the pointer comes with it.
|
|
83
|
+
*
|
|
84
|
+
* **The viewer's right is the negated X axis of the view rotation**, which is the one thing here
|
|
85
|
+
* that is easy to invert silently: meep's forward is +Z with up +Y, so a viewer facing along
|
|
86
|
+
* forward has world −X on their right. Both renderers read it that way — Shade builds its view
|
|
87
|
+
* matrix from `[−right, up, −forward]`, and the three camera the legacy path drives carries the
|
|
88
|
+
* object orientation with its forward negated, which flips the same axis.
|
|
89
|
+
*
|
|
90
|
+
* @param {Vector2} delta viewport pixels
|
|
91
|
+
* @param {TopDownCameraController} controller its {@link TopDownCameraController#target} is moved
|
|
92
|
+
* @param {number} viewport_height_px the perspective camera is fitted to height alone, so width
|
|
93
|
+
* plays no part
|
|
94
|
+
* @param {number} fov vertical field of view, in degrees
|
|
95
|
+
* @param {Vector3} [multiplier] per-axis scale on the world displacement; the strategy map zeroes Y
|
|
96
|
+
* to keep its target on the ground
|
|
97
|
+
*/
|
|
98
|
+
function pan(delta, controller, viewport_height_px, fov, multiplier = Vector3.one) {
|
|
99
|
+
assert.isNumber(viewport_height_px, 'viewport_height_px');
|
|
100
|
+
assert.isNumber(fov, 'fov');
|
|
101
|
+
|
|
102
|
+
// half of the fov is center to top of screen
|
|
103
|
+
const d = controller.distance * Math.tan(fov * deg2_in_rad);
|
|
104
|
+
|
|
105
|
+
const m = 2 * d / viewport_height_px;
|
|
106
|
+
|
|
107
|
+
top_down_view_rotation(q_view, controller);
|
|
108
|
+
|
|
109
|
+
v3_view_right.copy(Vector3.right);
|
|
110
|
+
v3_view_right.applyQuaternion(q_view);
|
|
111
|
+
v3_view_right.negate();
|
|
112
|
+
|
|
113
|
+
v3_view_up.copy(Vector3.up);
|
|
114
|
+
v3_view_up.applyQuaternion(q_view);
|
|
115
|
+
|
|
116
|
+
const target = controller.target;
|
|
117
|
+
|
|
118
|
+
move_along(target, v3_view_right, delta.x * m, multiplier);
|
|
119
|
+
|
|
120
|
+
// screen Y runs down the viewport and the view's up runs the other way
|
|
121
|
+
move_along(target, v3_view_up, -delta.y * m, multiplier);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class TopDownCameraController {
|
|
126
|
+
target = new Vector3();
|
|
127
|
+
pitch = 0;
|
|
128
|
+
yaw = 0;
|
|
129
|
+
roll = 0;
|
|
130
|
+
distance = 0;
|
|
131
|
+
distanceMin = 1;
|
|
132
|
+
distanceMax = 200;
|
|
133
|
+
|
|
134
|
+
constructor(options) {
|
|
135
|
+
//
|
|
136
|
+
if (options !== void 0) {
|
|
137
|
+
this.fromJSON(options);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Set target, rotation and distance from 2 vectors.
|
|
143
|
+
*
|
|
144
|
+
* `eye` must not coincide with `target`, and `up` must not be parallel to the direction between
|
|
145
|
+
* them — a degenerate basis has no angles to report and the caller gets an arbitrary one.
|
|
146
|
+
*
|
|
147
|
+
* @param {Vector3} eye
|
|
148
|
+
* @param {Vector3} target
|
|
149
|
+
* @param {Vector3} [up]
|
|
150
|
+
*/
|
|
151
|
+
setFromEyeAndTarget(eye, target, up = Vector3.up) {
|
|
152
|
+
|
|
153
|
+
v3_forward.copy(target);
|
|
154
|
+
v3_forward.sub(eye);
|
|
155
|
+
|
|
156
|
+
q_look.lookRotation(v3_forward, up);
|
|
157
|
+
|
|
158
|
+
m4_from_rotation_translation_scale_scalar(
|
|
159
|
+
m4,
|
|
160
|
+
q_look.x, q_look.y, q_look.z, q_look.w,
|
|
161
|
+
0, 0, 0,
|
|
162
|
+
1, 1, 1
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
m4_euler_angles(angles, m4, 2, 1, 0)
|
|
166
|
+
|
|
167
|
+
this.pitch = angles[2];
|
|
168
|
+
this.yaw = angles[1];
|
|
169
|
+
this.roll = angles[0];
|
|
170
|
+
|
|
171
|
+
this.distance = eye.distanceTo(target);
|
|
172
|
+
|
|
173
|
+
// ensure we can maintain this distance
|
|
174
|
+
this.distanceMax = max2(this.distance, this.distanceMax);
|
|
175
|
+
|
|
176
|
+
this.target.copy(target);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
*
|
|
181
|
+
* @param {TopDownCameraController} other
|
|
182
|
+
* @returns {boolean}
|
|
183
|
+
*/
|
|
184
|
+
equals(other) {
|
|
185
|
+
return this.target.equals(other.target)
|
|
186
|
+
&& this.pitch === other.pitch
|
|
187
|
+
&& this.yaw === other.yaw
|
|
188
|
+
&& this.roll === other.roll
|
|
189
|
+
&& this.distance === other.distance
|
|
190
|
+
&& this.distanceMin === other.distanceMin
|
|
191
|
+
&& this.distanceMax === other.distanceMax
|
|
192
|
+
;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
* @param {TopDownCameraController} other
|
|
198
|
+
*/
|
|
199
|
+
copy(other) {
|
|
200
|
+
this.target.copy(other.target);
|
|
201
|
+
|
|
202
|
+
this.pitch = other.pitch;
|
|
203
|
+
this.yaw = other.yaw;
|
|
204
|
+
this.roll = other.roll;
|
|
205
|
+
|
|
206
|
+
this.distance = other.distance;
|
|
207
|
+
this.distanceMax = other.distanceMax;
|
|
208
|
+
this.distanceMin = other.distanceMin;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
*
|
|
213
|
+
* @returns {TopDownCameraController}
|
|
214
|
+
*/
|
|
215
|
+
clone() {
|
|
216
|
+
const r = new TopDownCameraController();
|
|
217
|
+
|
|
218
|
+
r.copy(this);
|
|
219
|
+
|
|
220
|
+
return r;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
*
|
|
225
|
+
* @param {TopDownCameraController} a
|
|
226
|
+
* @param {TopDownCameraController} b
|
|
227
|
+
* @param {number} t
|
|
228
|
+
*/
|
|
229
|
+
lerp(a, b, t) {
|
|
230
|
+
this.target.lerpVectors(a.target, b.target, t);
|
|
231
|
+
|
|
232
|
+
this.pitch = lerp(a.pitch, b.pitch, t);
|
|
233
|
+
this.yaw = lerp(a.yaw, b.yaw, t);
|
|
234
|
+
this.roll = lerp(a.roll, b.roll, t);
|
|
235
|
+
|
|
236
|
+
this.distance = lerp(a.distance, b.distance, t);
|
|
237
|
+
|
|
238
|
+
this.distanceMin = lerp(a.distanceMin, b.distanceMin, t);
|
|
239
|
+
this.distanceMax = lerp(a.distanceMax, b.distanceMax, t);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
toJSON() {
|
|
243
|
+
return {
|
|
244
|
+
target: this.target.toJSON(),
|
|
245
|
+
|
|
246
|
+
pitch: this.pitch,
|
|
247
|
+
yaw: this.yaw,
|
|
248
|
+
roll: this.roll,
|
|
249
|
+
|
|
250
|
+
distance: this.distance,
|
|
251
|
+
distanceMin: this.distanceMin,
|
|
252
|
+
distanceMax: this.distanceMax
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
fromJSON(
|
|
257
|
+
{
|
|
258
|
+
distance = 0,
|
|
259
|
+
distanceMin = 0,
|
|
260
|
+
distanceMax = 0,
|
|
261
|
+
pitch = 0,
|
|
262
|
+
yaw = 0,
|
|
263
|
+
roll = 0,
|
|
264
|
+
target = Vector3.zero,
|
|
265
|
+
}
|
|
266
|
+
) {
|
|
267
|
+
|
|
268
|
+
this.distance = distance;
|
|
269
|
+
this.distanceMin = distanceMin;
|
|
270
|
+
this.distanceMax = distanceMax;
|
|
271
|
+
|
|
272
|
+
this.pitch = pitch;
|
|
273
|
+
this.roll = roll;
|
|
274
|
+
this.yaw = yaw;
|
|
275
|
+
|
|
276
|
+
this.target.fromJSON(target);
|
|
277
|
+
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
static fromJSON(j) {
|
|
281
|
+
const r = new TopDownCameraController();
|
|
282
|
+
|
|
283
|
+
r.fromJSON(j);
|
|
284
|
+
|
|
285
|
+
return r;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
TopDownCameraController.typeName = "TopDownCameraController";
|
|
290
|
+
|
|
291
|
+
TopDownCameraController.pan = pan;
|
|
292
|
+
TopDownCameraController.rotate = rotate_from_view;
|
|
293
|
+
|
|
294
|
+
export default TopDownCameraController;
|
|
295
|
+
|
|
296
|
+
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* WHY THIS EXISTS
|
|
7
7
|
*
|
|
8
|
-
* `
|
|
8
|
+
* `extend_shadow_camera_near_for_casters` and the camera auto-clipping pass that has since gone
|
|
9
9
|
* each restated two things verbatim:
|
|
10
10
|
*
|
|
11
11
|
* - the three.js matrix-layout invariant that a camera's view direction is the
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* WHY THIS EXISTS
|
|
7
7
|
*
|
|
8
|
-
* `
|
|
8
|
+
* `extend_shadow_camera_near_for_casters` and the camera auto-clipping pass that has since gone
|
|
9
9
|
* each restated two things verbatim:
|
|
10
10
|
*
|
|
11
11
|
* - the three.js matrix-layout invariant that a camera's view direction is the
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An {@link AttributeSpec} and the elements stored under it.
|
|
3
|
+
*
|
|
4
|
+
* The spec says what one item is — how many components, in what type, whether integer values are
|
|
5
|
+
* read back normalized — and the array holds `count` of them end to end. Nothing here knows about a
|
|
6
|
+
* renderer: uploading is the business of whoever is drawing, and a consumer that re-reads the array
|
|
7
|
+
* every frame has nothing to be told.
|
|
8
|
+
*/
|
|
9
|
+
export class AttributeData {
|
|
10
|
+
/**
|
|
11
|
+
* Allocate storage for `count` items of `spec`.
|
|
12
|
+
*
|
|
13
|
+
* @param {AttributeSpec} spec
|
|
14
|
+
* @param {number} count
|
|
15
|
+
* @returns {AttributeData}
|
|
16
|
+
*/
|
|
17
|
+
static allocate(spec: AttributeSpec, count: number): AttributeData;
|
|
18
|
+
/**
|
|
19
|
+
* @param {AttributeSpec} spec
|
|
20
|
+
* @param {Float32Array|Float64Array|Uint8Array|Uint16Array|Uint32Array|Int8Array|Int16Array|Int32Array} array
|
|
21
|
+
*/
|
|
22
|
+
constructor(spec: AttributeSpec, array: Float32Array | Float64Array | Uint8Array | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array);
|
|
23
|
+
/**
|
|
24
|
+
* @type {AttributeSpec}
|
|
25
|
+
*/
|
|
26
|
+
spec: AttributeSpec;
|
|
27
|
+
/**
|
|
28
|
+
* `count * spec.itemSize` elements, item-major.
|
|
29
|
+
*
|
|
30
|
+
* @type {Float32Array|Float64Array|Uint8Array|Uint16Array|Uint32Array|Int8Array|Int16Array|Int32Array}
|
|
31
|
+
*/
|
|
32
|
+
array: Float32Array | Float64Array | Uint8Array | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array;
|
|
33
|
+
/**
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
get name(): string;
|
|
37
|
+
/**
|
|
38
|
+
* @returns {number}
|
|
39
|
+
*/
|
|
40
|
+
get itemSize(): number;
|
|
41
|
+
/**
|
|
42
|
+
* @returns {boolean}
|
|
43
|
+
*/
|
|
44
|
+
get normalized(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* How many items the array has room for.
|
|
47
|
+
*
|
|
48
|
+
* @returns {number}
|
|
49
|
+
*/
|
|
50
|
+
get count(): number;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=AttributeData.d.ts.map
|