@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,303 +1,165 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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
|
-
this.
|
|
122
|
-
this.
|
|
123
|
-
this.
|
|
124
|
-
this.
|
|
125
|
-
this.
|
|
126
|
-
this.
|
|
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
|
-
static projectRay(
|
|
168
|
-
camera,
|
|
169
|
-
x, y,
|
|
170
|
-
out_source, out_direction
|
|
171
|
-
) {
|
|
172
|
-
assert.defined(camera, "camera");
|
|
173
|
-
assert.defined(camera.position, "Camera.position");
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
assert.isNumber(x, 'x');
|
|
177
|
-
assert.isNumber(y, "y");
|
|
178
|
-
|
|
179
|
-
// assert.ok(x >= -1, `X(=${x}) must be greater than or equal to -1.0, not a clip-space coordinate`);
|
|
180
|
-
// assert.ok(x <= 1, `X(=${x}) must be less than or equal to 1.0, not a clip-space coordinate`);
|
|
181
|
-
|
|
182
|
-
// assert.ok(y >= -1, `Y(=${y}) must be greater than or equal to -1.0, not a clip-space coordinate`);
|
|
183
|
-
// assert.ok(y <= 1, `Y(=${y}) must be less than or equal to 1.0, not a clip-space coordinate`);
|
|
184
|
-
|
|
185
|
-
if (camera.isPerspectiveCamera || camera.isOrthographicCamera) {
|
|
186
|
-
const m4_world = camera.matrixWorld.elements;
|
|
187
|
-
const m4_projection_inverse = camera.projectionMatrixInverse.elements;
|
|
188
|
-
|
|
189
|
-
scratch_v3_1.setFromMatrixPosition(m4_world);
|
|
190
|
-
|
|
191
|
-
scratch_v3_0.set(x, y, 0.5);
|
|
192
|
-
|
|
193
|
-
// NOTE: projection inverse and world matrices are used in "unproject" operation, we update those to make things work as intended. This is handled by the camera system
|
|
194
|
-
|
|
195
|
-
unprojectPoint(
|
|
196
|
-
scratch_v3_0,
|
|
197
|
-
scratch_v3_0,
|
|
198
|
-
m4_projection_inverse,
|
|
199
|
-
m4_world
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
//get direction
|
|
203
|
-
scratch_v3_0.sub(scratch_v3_1);
|
|
204
|
-
scratch_v3_0.normalize();
|
|
205
|
-
|
|
206
|
-
out_source.copy(scratch_v3_1);
|
|
207
|
-
out_direction.copy(scratch_v3_0);
|
|
208
|
-
|
|
209
|
-
} else {
|
|
210
|
-
throw new Error('Unsupported camera type');
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
*
|
|
216
|
-
* @param {Matrix4} result
|
|
217
|
-
*/
|
|
218
|
-
computeProjectionMatrix(result) {
|
|
219
|
-
const camera = this.object;
|
|
220
|
-
|
|
221
|
-
if (camera === null) {
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
result.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
226
|
-
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
*
|
|
232
|
-
* @param {Vector3} out
|
|
233
|
-
* @param {number} origin_x
|
|
234
|
-
* @param {number} origin_y
|
|
235
|
-
* @param {number} origin_z
|
|
236
|
-
* @param {number} direction_x
|
|
237
|
-
* @param {number} direction_y
|
|
238
|
-
* @param {number} direction_z
|
|
239
|
-
* @param {number} plane_index
|
|
240
|
-
*/
|
|
241
|
-
rayPlaneIntersection(
|
|
242
|
-
out,
|
|
243
|
-
origin_x, origin_y, origin_z,
|
|
244
|
-
direction_x, direction_y, direction_z,
|
|
245
|
-
plane_index
|
|
246
|
-
) {
|
|
247
|
-
|
|
248
|
-
assert.isNonNegativeInteger(plane_index, 'plane_index');
|
|
249
|
-
assert.lessThanOrEqual(plane_index, 5, `plane_index must be <= 5, was ${plane_index}`)
|
|
250
|
-
|
|
251
|
-
frustum_from_camera(this.object, scratch_frustum);
|
|
252
|
-
|
|
253
|
-
const plane = scratch_frustum.planes[plane_index];
|
|
254
|
-
|
|
255
|
-
assert.defined(plane, 'plane');
|
|
256
|
-
|
|
257
|
-
plane3_compute_ray_intersection(
|
|
258
|
-
out,
|
|
259
|
-
origin_x, origin_y, origin_z,
|
|
260
|
-
direction_x, direction_y, direction_z,
|
|
261
|
-
plane.normal.x, plane.normal.y, plane.normal.z,
|
|
262
|
-
plane.constant
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
*
|
|
268
|
-
* @param {number} x
|
|
269
|
-
* @param {number} y
|
|
270
|
-
* @param {number} z
|
|
271
|
-
* @param {Vector3} result
|
|
272
|
-
*/
|
|
273
|
-
projectWorldPointOntoNearPlane(x, y, z, result) {
|
|
274
|
-
|
|
275
|
-
frustum_from_camera(this.object, scratch_frustum);
|
|
276
|
-
|
|
277
|
-
const near = scratch_frustum.planes[0];
|
|
278
|
-
|
|
279
|
-
scratch_v3_0.set(x, y, z);
|
|
280
|
-
|
|
281
|
-
const normal = near.normal;
|
|
282
|
-
|
|
283
|
-
const distance_to_plane = v3_distance_above_plane(x, y, z, normal.x, normal.y, normal.z, near.constant);
|
|
284
|
-
|
|
285
|
-
const negative_distance_to_plane = -distance_to_plane;
|
|
286
|
-
|
|
287
|
-
result.set(
|
|
288
|
-
normal.x * negative_distance_to_plane + x,
|
|
289
|
-
normal.y * negative_distance_to_plane + y,
|
|
290
|
-
normal.z * negative_distance_to_plane + z,
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
Camera.typeName = "Camera";
|
|
296
|
-
|
|
297
|
-
Camera.ProjectionType = ProjectionType;
|
|
298
|
-
|
|
299
|
-
const scratch_v3_0 = new Vector3();
|
|
300
|
-
const scratch_v3_1 = new Vector3();
|
|
301
|
-
const scratch_frustum = new Frustum();
|
|
302
|
-
|
|
303
|
-
|
|
1
|
+
import Vector1 from "../../../../core/geom/Vector1.js";
|
|
2
|
+
import ObservedBoolean from "../../../../core/model/ObservedBoolean.js";
|
|
3
|
+
import ObservedEnum from "../../../../core/model/ObservedEnum.js";
|
|
4
|
+
import { ProjectionType } from "./ProjectionType.js";
|
|
5
|
+
import { quaternion_invert_orientation } from "./quaternion_invert_orientation.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @class
|
|
9
|
+
*/
|
|
10
|
+
export class Camera {
|
|
11
|
+
/**
|
|
12
|
+
* Whether clipping planes should be automatically calculated or not.
|
|
13
|
+
*
|
|
14
|
+
* **Nothing reads this.** The pass that tightened the planes measured the depth range of the
|
|
15
|
+
* renderer's own layers, which no renderer has offered since the three path was removed; the
|
|
16
|
+
* field stays because it is on the wire and a level carries it.
|
|
17
|
+
*
|
|
18
|
+
* @type {boolean}
|
|
19
|
+
*/
|
|
20
|
+
autoClip = false;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Tunable parameter to prevent clipping planes from thrashing. Clipping planes must move by a certain portion of the current span before frustum gets shrunken
|
|
24
|
+
*
|
|
25
|
+
* Inert for the same reason as {@link autoClip}, and kept for the same one.
|
|
26
|
+
*
|
|
27
|
+
* @type {number}
|
|
28
|
+
*/
|
|
29
|
+
autoClipHysteresis = 0.33;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @type {Float32Array}
|
|
33
|
+
*/
|
|
34
|
+
#frustum = new Float32Array(24);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
*/
|
|
39
|
+
#has_frustum = false;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @type {Vector1}
|
|
44
|
+
*/
|
|
45
|
+
fov = new Vector1(45);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @type {ObservedEnum<ProjectionType>}
|
|
50
|
+
*/
|
|
51
|
+
projectionType = new ObservedEnum(ProjectionType.Perspective, ProjectionType);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @type {ObservedBoolean}
|
|
56
|
+
*/
|
|
57
|
+
active = new ObservedBoolean(true);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Far clipping plane
|
|
61
|
+
* @type {number}
|
|
62
|
+
*/
|
|
63
|
+
clip_far = 100;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Near clipping plane
|
|
67
|
+
* @type {number}
|
|
68
|
+
*/
|
|
69
|
+
clip_near = 0.1;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The planes of the frame this camera last drew — six
|
|
73
|
+
* `[normal_x, normal_y, normal_z, constant]` tuples, the layout every frustum query in the tree
|
|
74
|
+
* reads — or `null` when it has not drawn one.
|
|
75
|
+
*
|
|
76
|
+
* A method rather than a property because it is not one: the inspector draws a row for every
|
|
77
|
+
* readable property a component has, and this is an answer the renderer gave, not a field
|
|
78
|
+
* anybody authors. The planes are rewritten under the caller every tick.
|
|
79
|
+
*
|
|
80
|
+
* @returns {Float32Array|null}
|
|
81
|
+
*/
|
|
82
|
+
getFrustumPlanes() {
|
|
83
|
+
if (!this.#has_frustum) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return this.#frustum;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Record the planes the frame was drawn with.
|
|
92
|
+
*
|
|
93
|
+
* The renderer's camera is what computes them, because the frustum a gameplay query wants is
|
|
94
|
+
* the one the picture was actually drawn with; deriving a second one from the field of view
|
|
95
|
+
* here would need the aspect ratio, which belongs to whatever surface the frame is going out at
|
|
96
|
+
* and not to a camera entity.
|
|
97
|
+
*
|
|
98
|
+
* @param {Float32Array|number[]} planes six `[normal_x, normal_y, normal_z, constant]` tuples
|
|
99
|
+
*/
|
|
100
|
+
publishFrustum(planes) {
|
|
101
|
+
this.#frustum.set(planes);
|
|
102
|
+
|
|
103
|
+
this.#has_frustum = true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* @param {Quaternion} output
|
|
109
|
+
* @param {Quaternion} input
|
|
110
|
+
*/
|
|
111
|
+
getReciprocalRotation(output, input) {
|
|
112
|
+
quaternion_invert_orientation(output, input);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @param {Camera} other
|
|
118
|
+
*/
|
|
119
|
+
copy(other) {
|
|
120
|
+
this.active.copy(other.active);
|
|
121
|
+
this.projectionType.copy(other.projectionType);
|
|
122
|
+
this.autoClip = other.autoClip;
|
|
123
|
+
this.autoClipHysteresis = other.autoClipHysteresis;
|
|
124
|
+
this.fov.copy(other.fov);
|
|
125
|
+
this.clip_near = other.clip_near;
|
|
126
|
+
this.clip_far = other.clip_far;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @returns {Camera}
|
|
132
|
+
*/
|
|
133
|
+
clone() {
|
|
134
|
+
const clone = new Camera();
|
|
135
|
+
|
|
136
|
+
clone.copy(this);
|
|
137
|
+
|
|
138
|
+
return clone;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
toJSON() {
|
|
142
|
+
return {
|
|
143
|
+
autoClip: this.autoClip,
|
|
144
|
+
active: this.active.toJSON()
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
fromJSON(json) {
|
|
149
|
+
this.autoClip = json.autoClip;
|
|
150
|
+
|
|
151
|
+
if (typeof json.active === "boolean") {
|
|
152
|
+
this.active.fromJSON(json.active);
|
|
153
|
+
} else {
|
|
154
|
+
this.active.set(false);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
Camera.typeName = "Camera";
|
|
161
|
+
|
|
162
|
+
Camera.ProjectionType = ProjectionType;
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The world-space frustum of the frame, or `null` when nothing is drawing one.
|
|
3
|
+
*
|
|
4
|
+
* Six `[normal_x, normal_y, normal_z, constant]` tuples, the layout every frustum query in the tree
|
|
5
|
+
* reads — a point is inside when `normal · p + constant` is non-negative for all six.
|
|
6
|
+
*
|
|
7
|
+
* The planes belong to the camera component and are rewritten every tick, so a caller holds the
|
|
8
|
+
* answer for the length of its own call and no longer.
|
|
9
|
+
*
|
|
10
|
+
* @param {EntityComponentDataset} ecd
|
|
11
|
+
* @returns {Float32Array|null}
|
|
12
|
+
*/
|
|
13
|
+
export function camera_active_frustum(ecd: EntityComponentDataset): Float32Array | null;
|
|
14
|
+
//# sourceMappingURL=camera_active_frustum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera_active_frustum.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/camera_active_frustum.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,oEAFa,YAAY,GAAC,IAAI,CAY7B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { camera_find_active } from "./camera_find_active.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The world-space frustum of the frame, or `null` when nothing is drawing one.
|
|
5
|
+
*
|
|
6
|
+
* Six `[normal_x, normal_y, normal_z, constant]` tuples, the layout every frustum query in the tree
|
|
7
|
+
* reads — a point is inside when `normal · p + constant` is non-negative for all six.
|
|
8
|
+
*
|
|
9
|
+
* The planes belong to the camera component and are rewritten every tick, so a caller holds the
|
|
10
|
+
* answer for the length of its own call and no longer.
|
|
11
|
+
*
|
|
12
|
+
* @param {EntityComponentDataset} ecd
|
|
13
|
+
* @returns {Float32Array|null}
|
|
14
|
+
*/
|
|
15
|
+
export function camera_active_frustum(ecd) {
|
|
16
|
+
const { component } = camera_find_active(ecd);
|
|
17
|
+
|
|
18
|
+
if (component === undefined) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// a camera that has not driven a frame yet answers `null`; zeroed planes would say "everything
|
|
23
|
+
// is visible", which is an answer rather than an admission
|
|
24
|
+
return component.getFrustumPlanes();
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The camera entity the frame is drawn from, or an entity of `-1` when the dataset has none.
|
|
3
|
+
*
|
|
4
|
+
* **The first active one wins**, which is the rule `CameraSystem3` settles on when it elects the
|
|
5
|
+
* camera it copies onto the renderer's. Two entities both claiming to be active therefore resolve
|
|
6
|
+
* the same way here as they do there; the predecessor of this function took the last one and could
|
|
7
|
+
* name a camera nothing was drawing from.
|
|
8
|
+
*
|
|
9
|
+
* @param {EntityComponentDataset} ecd
|
|
10
|
+
* @returns {{component: (Camera|undefined), entity: number}}
|
|
11
|
+
*/
|
|
12
|
+
export function camera_find_active(ecd: EntityComponentDataset): {
|
|
13
|
+
component: (Camera | undefined);
|
|
14
|
+
entity: number;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=camera_find_active.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera_find_active.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/camera_find_active.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,iEAFa;IAAC,SAAS,EAAE,CAAC,SAAO,SAAS,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAgB3D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { camera_traverse_active } from "./camera_traverse_active.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The camera entity the frame is drawn from, or an entity of `-1` when the dataset has none.
|
|
5
|
+
*
|
|
6
|
+
* **The first active one wins**, which is the rule `CameraSystem3` settles on when it elects the
|
|
7
|
+
* camera it copies onto the renderer's. Two entities both claiming to be active therefore resolve
|
|
8
|
+
* the same way here as they do there; the predecessor of this function took the last one and could
|
|
9
|
+
* name a camera nothing was drawing from.
|
|
10
|
+
*
|
|
11
|
+
* @param {EntityComponentDataset} ecd
|
|
12
|
+
* @returns {{component: (Camera|undefined), entity: number}}
|
|
13
|
+
*/
|
|
14
|
+
export function camera_find_active(ecd) {
|
|
15
|
+
const result = {
|
|
16
|
+
entity: -1,
|
|
17
|
+
component: undefined
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
camera_traverse_active(ecd, (camera, entity) => {
|
|
21
|
+
if (result.entity === -1) {
|
|
22
|
+
result.entity = entity;
|
|
23
|
+
result.component = camera;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visit every camera entity that claims to be active.
|
|
3
|
+
*
|
|
4
|
+
* More than one may claim it; only one of them drives the frame, and which one that is belongs to
|
|
5
|
+
* {@link camera_find_active}.
|
|
6
|
+
*
|
|
7
|
+
* @param {EntityComponentDataset} ecd
|
|
8
|
+
* @param {(camera: Camera, entity: number) => void} visitor
|
|
9
|
+
*/
|
|
10
|
+
export function camera_traverse_active(ecd: EntityComponentDataset, visitor: (camera: Camera, entity: number) => void): void;
|
|
11
|
+
import { Camera } from "./Camera.js";
|
|
12
|
+
//# sourceMappingURL=camera_traverse_active.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera_traverse_active.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/camera_traverse_active.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,sFAFoB,MAAM,UAAU,MAAM,KAAK,IAAI,QAQlD;uBAjBsB,aAAa"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Camera } from "./Camera.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Visit every camera entity that claims to be active.
|
|
5
|
+
*
|
|
6
|
+
* More than one may claim it; only one of them drives the frame, and which one that is belongs to
|
|
7
|
+
* {@link camera_find_active}.
|
|
8
|
+
*
|
|
9
|
+
* @param {EntityComponentDataset} ecd
|
|
10
|
+
* @param {(camera: Camera, entity: number) => void} visitor
|
|
11
|
+
*/
|
|
12
|
+
export function camera_traverse_active(ecd, visitor) {
|
|
13
|
+
ecd.traverseComponents(Camera, function (camera, entity) {
|
|
14
|
+
if (camera.active.getValue()) {
|
|
15
|
+
visitor(camera, entity);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|