@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,331 +0,0 @@
|
|
|
1
|
-
import { Frustum as ThreeFrustum, } from 'three';
|
|
2
|
-
import { assert } from "../../../../core/assert.js";
|
|
3
|
-
import { SignalBinding } from "../../../../core/events/signal/SignalBinding.js";
|
|
4
|
-
import Quaternion from "../../../../core/geom/Quaternion.js";
|
|
5
|
-
import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
|
|
6
|
-
import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
|
|
7
|
-
import { System } from '../../../ecs/System.js';
|
|
8
|
-
import { Transform } from '../../../ecs/transform/Transform.js';
|
|
9
|
-
import { threeUpdateTransform } from "../../util/threeUpdateTransform.js";
|
|
10
|
-
import { auto_set_camera_clipping_planes } from "./auto_set_camera_clipping_planes.js";
|
|
11
|
-
import { build_three_camera_object } from "./build_three_camera_object.js";
|
|
12
|
-
import { Camera } from './Camera.js';
|
|
13
|
-
import { frustum_from_camera } from "./frustum_from_camera.js";
|
|
14
|
-
import { quaternion_invert_orientation } from "./quaternion_invert_orientation.js";
|
|
15
|
-
import { set_camera_aspect_ratio } from "./set_camera_aspect_ratio.js";
|
|
16
|
-
import { update_camera_transform } from "./update_camera_transform.js";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const scratch_quat = new Quaternion();
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {THREE.Camera} object
|
|
24
|
-
* @param {Quaternion} rotation
|
|
25
|
-
*/
|
|
26
|
-
export function three_camera_set_transform_rotation(object, rotation) {
|
|
27
|
-
|
|
28
|
-
/*
|
|
29
|
-
NOTE: I'm not sure why, but three.js camera points in the opposite direction to normal objects
|
|
30
|
-
See: https://github.com/mrdoob/three.js/blob/412b99a7f26e117ea97f40eb53d010ab81aa3279/src/core/Object3D.js#L282
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
quaternion_invert_orientation(scratch_quat, rotation);
|
|
34
|
-
|
|
35
|
-
object.quaternion.set(
|
|
36
|
-
scratch_quat.x, scratch_quat.y, scratch_quat.z, scratch_quat.w
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
object.rotation.setFromQuaternion(object.quaternion);
|
|
40
|
-
|
|
41
|
-
// rotation.__setThreeEuler(camera.object.rotation); // seems unnecessary, based on Object3D.lookAt implementation
|
|
42
|
-
// camera.object.quaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
43
|
-
|
|
44
|
-
object.updateProjectionMatrix();
|
|
45
|
-
threeUpdateTransform(object);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export class CameraSystem extends System {
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
* @type {EntityManager}
|
|
52
|
-
*/
|
|
53
|
-
entityManager = null;
|
|
54
|
-
|
|
55
|
-
entityData = [];
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* @param {GraphicsEngine} graphics
|
|
60
|
-
* @constructor
|
|
61
|
-
*/
|
|
62
|
-
constructor(graphics) {
|
|
63
|
-
super();
|
|
64
|
-
|
|
65
|
-
assert.defined(graphics, 'graphics');
|
|
66
|
-
assert.notNull(graphics, 'graphics');
|
|
67
|
-
assert.equal(graphics.isGraphicsEngine, true, 'graphics.isGraphicsEngine !== true');
|
|
68
|
-
|
|
69
|
-
this.scene = graphics.scene;
|
|
70
|
-
|
|
71
|
-
this.dependencies = [Camera, Transform];
|
|
72
|
-
|
|
73
|
-
this.components_used = [
|
|
74
|
-
ResourceAccessSpecification.from(Camera, ResourceAccessKind.Write)
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @type {GraphicsEngine}
|
|
79
|
-
*/
|
|
80
|
-
this.graphics = graphics;
|
|
81
|
-
|
|
82
|
-
const self = this;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
86
|
-
* @param {number} x
|
|
87
|
-
* @param {number} y
|
|
88
|
-
* @private
|
|
89
|
-
*/
|
|
90
|
-
this.__handleViewportResize = function (x, y) {
|
|
91
|
-
const em = self.entityManager;
|
|
92
|
-
if (em === null) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const dataset = em.dataset;
|
|
97
|
-
|
|
98
|
-
if (dataset === null) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
dataset.traverseComponents(Camera, function (camera) {
|
|
103
|
-
set_camera_aspect_ratio(camera, x, y);
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
this.signalBindings = [];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
* @param {Transform} transform
|
|
114
|
-
* @param {Camera} camera
|
|
115
|
-
* @param entityId
|
|
116
|
-
*/
|
|
117
|
-
link(camera, transform, entityId) {
|
|
118
|
-
if (camera.object === null) {
|
|
119
|
-
camera.object = build_three_camera_object(camera);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const graphics = this.graphics;
|
|
123
|
-
|
|
124
|
-
const viewportSize = graphics.viewport.size;
|
|
125
|
-
|
|
126
|
-
set_camera_aspect_ratio(camera, viewportSize.x, viewportSize.y);
|
|
127
|
-
|
|
128
|
-
this.scene.add(camera.object);
|
|
129
|
-
|
|
130
|
-
function synchronizePosition(x, y, z) {
|
|
131
|
-
assert.isNumber(x, 'x');
|
|
132
|
-
assert.isNumber(y, 'y');
|
|
133
|
-
assert.isNumber(z, 'z');
|
|
134
|
-
|
|
135
|
-
camera.object.position.set(x, y, z);
|
|
136
|
-
update_camera_transform(camera);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function synchronizeRotation() {
|
|
140
|
-
const rotation = transform.rotation;
|
|
141
|
-
|
|
142
|
-
three_camera_set_transform_rotation(camera.object, rotation);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function rebuild() {
|
|
146
|
-
camera.object = build_three_camera_object(camera);
|
|
147
|
-
set_camera_aspect_ratio(camera, viewportSize.x, viewportSize.y);
|
|
148
|
-
|
|
149
|
-
const position = transform.position;
|
|
150
|
-
|
|
151
|
-
synchronizePosition(position.x, position.y, position.z);
|
|
152
|
-
synchronizeRotation();
|
|
153
|
-
|
|
154
|
-
synchronizeActiveState(camera.active.getValue());
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function synchronizeActiveState(v) {
|
|
158
|
-
if (v) {
|
|
159
|
-
graphics.camera = camera.object;
|
|
160
|
-
} else {
|
|
161
|
-
//active camera disabled
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const position = transform.position;
|
|
166
|
-
const rotation = transform.rotation;
|
|
167
|
-
|
|
168
|
-
const signalBindings = [
|
|
169
|
-
new SignalBinding(position.onChanged, synchronizePosition),
|
|
170
|
-
new SignalBinding(rotation.onChanged, synchronizeRotation),
|
|
171
|
-
new SignalBinding(camera.projectionType.onChanged, rebuild),
|
|
172
|
-
new SignalBinding(camera.active.onChanged, synchronizeActiveState),
|
|
173
|
-
new SignalBinding(camera.fov.onChanged, rebuild)
|
|
174
|
-
];
|
|
175
|
-
|
|
176
|
-
signalBindings.forEach(b => b.link());
|
|
177
|
-
|
|
178
|
-
this.entityData[entityId] = signalBindings;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
synchronizePosition(position.x, position.y, position.z);
|
|
182
|
-
synchronizeRotation(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
183
|
-
synchronizeActiveState(camera.active.getValue());
|
|
184
|
-
|
|
185
|
-
assert.notEqual(camera.object, null, 'Camera object must not be null (invariant)');
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
*
|
|
190
|
-
* @param {Transform} transform
|
|
191
|
-
* @param {Camera} camera
|
|
192
|
-
* @param entityId
|
|
193
|
-
*/
|
|
194
|
-
unlink(camera, transform, entityId) {
|
|
195
|
-
const data = this.entityData;
|
|
196
|
-
if (data.hasOwnProperty(entityId)) {
|
|
197
|
-
const entityData = data[entityId];
|
|
198
|
-
|
|
199
|
-
if (entityData !== void 0) {
|
|
200
|
-
entityData.forEach(b => b.unlink());
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
delete data[entityId];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
this.scene.remove(camera.object);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async startup(entityManager) {
|
|
210
|
-
this.entityManager = entityManager;
|
|
211
|
-
|
|
212
|
-
const graphics = this.graphics;
|
|
213
|
-
|
|
214
|
-
graphics.viewport.size.onChanged.add(this.__handleViewportResize);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const visibilityConstructionPreHook = new SignalBinding(graphics.on.visibilityConstructionStarted, function () {
|
|
218
|
-
const em = entityManager;
|
|
219
|
-
|
|
220
|
-
const layers = graphics.layers;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const dataset = em.dataset;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
*
|
|
227
|
-
* @param {Camera} c
|
|
228
|
-
*/
|
|
229
|
-
function visitCameraEntity(c) {
|
|
230
|
-
if (c.object === null) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (!c.active.getValue()) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (c.object.updateProjectionMatrix !== undefined) {
|
|
239
|
-
c.object.updateProjectionMatrix();
|
|
240
|
-
c.object.updateMatrix();
|
|
241
|
-
c.object.updateMatrixWorld(true);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (c.autoClip === true) {
|
|
245
|
-
auto_set_camera_clipping_planes(c, layers);
|
|
246
|
-
} else {
|
|
247
|
-
c.object.far = c.clip_far;
|
|
248
|
-
c.object.near = c.clip_near;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (dataset !== null) {
|
|
253
|
-
dataset.traverseComponents(Camera, visitCameraEntity);
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
visibilityConstructionPreHook.link();
|
|
258
|
-
|
|
259
|
-
this.signalBindings.push(visibilityConstructionPreHook);
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
async shutdown(entityManager) {
|
|
264
|
-
this.graphics.viewport.size.onChanged.remove(this.__handleViewportResize);
|
|
265
|
-
|
|
266
|
-
this.signalBindings.forEach(sb => sb.unlink());
|
|
267
|
-
|
|
268
|
-
this.signalBindings.splice(0, this.signalBindings.length);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
*
|
|
273
|
-
* @param {EntityComponentDataset} ecd
|
|
274
|
-
* @param {(camera: Camera, entity: number) => void} visitor
|
|
275
|
-
*/
|
|
276
|
-
static traverseActiveCameras(ecd, visitor) {
|
|
277
|
-
|
|
278
|
-
ecd.traverseComponents(Camera, function (c, entity) {
|
|
279
|
-
if (c.active.getValue()) {
|
|
280
|
-
visitor(c, entity);
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
*
|
|
287
|
-
* @param {EntityComponentDataset} ecd
|
|
288
|
-
* @returns {{component:(Camera|undefined), entity: number}}
|
|
289
|
-
*/
|
|
290
|
-
static getFirstActiveCamera(ecd) {
|
|
291
|
-
const r = {
|
|
292
|
-
entity: -1,
|
|
293
|
-
component: undefined
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
this.traverseActiveCameras(ecd, (c, e) => {
|
|
297
|
-
r.entity = e;
|
|
298
|
-
r.component = c;
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
return r;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
*
|
|
306
|
-
* @param {EntityComponentDataset} ecd
|
|
307
|
-
* @param {function(ThreeFrustum[])} callback
|
|
308
|
-
*/
|
|
309
|
-
static getActiveFrustums(ecd, callback) {
|
|
310
|
-
const frustums = [];
|
|
311
|
-
|
|
312
|
-
if (ecd !== null) {
|
|
313
|
-
ecd.traverseComponents(Camera, function (c) {
|
|
314
|
-
if (c.active.getValue()) {
|
|
315
|
-
const camera = c.object;
|
|
316
|
-
|
|
317
|
-
if (camera !== null) {
|
|
318
|
-
const frustum = new ThreeFrustum();
|
|
319
|
-
frustum_from_camera(camera, frustum);
|
|
320
|
-
frustums.push(frustum);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
callback(frustums);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tighten the camera's near/far planes to the world-space depth range of all
|
|
3
|
-
* BVH-backed render layers' content visible inside the camera's frustum. Falls
|
|
4
|
-
* back to (clip_near, clip_far) when no layer contributes content.
|
|
5
|
-
*
|
|
6
|
-
* @param {Camera} c camera ECS component (its `object` is the THREE.Camera)
|
|
7
|
-
* @param {RenderLayerManager} layers
|
|
8
|
-
*/
|
|
9
|
-
export function auto_set_camera_clipping_planes(c: Camera, layers: RenderLayerManager): void;
|
|
10
|
-
//# sourceMappingURL=auto_set_camera_clipping_planes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto_set_camera_clipping_planes.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.js"],"names":[],"mappings":"AA0BA;;;;;;;GAOG;AACH,6FAqEC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { Frustum as ThreeFrustum } from "three";
|
|
2
|
-
import { frustum3_planes_to_flat_from_three } from "../../../../core/geom/3d/frustum/frustum3_planes_to_flat_from_three.js";
|
|
3
|
-
import { render_layers_compute_depth_range } from "../render_layers_compute_depth_range.js";
|
|
4
|
-
import { frustum_from_camera } from "./frustum_from_camera.js";
|
|
5
|
-
|
|
6
|
-
const CLIPPING_EPSILON = 0.001;
|
|
7
|
-
const CLIPPING_NEAR_MIN = 0.5;
|
|
8
|
-
const CLIPPING_FAR_DEFAULT = 100;
|
|
9
|
-
|
|
10
|
-
const scratch_three_frustum = new ThreeFrustum();
|
|
11
|
-
const scratch_frustum_planes = new Float32Array(24);
|
|
12
|
-
const scratch_range = { near: 0, far: 0 };
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Hysteresis prevents the clipping planes from thrashing as content moves
|
|
16
|
-
* slightly. A shrink is only honored when it's at least this fraction of the
|
|
17
|
-
* current near-to-far span; smaller shrinks are ignored, so an object briefly
|
|
18
|
-
* crossing the frustum boundary doesn't trigger a re-projection.
|
|
19
|
-
*
|
|
20
|
-
* Loosenings (when content moves further away or closer) always apply
|
|
21
|
-
* immediately — never delay including content.
|
|
22
|
-
*
|
|
23
|
-
* @type {number}
|
|
24
|
-
*/
|
|
25
|
-
const HYSTERESIS = 0.33;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Tighten the camera's near/far planes to the world-space depth range of all
|
|
29
|
-
* BVH-backed render layers' content visible inside the camera's frustum. Falls
|
|
30
|
-
* back to (clip_near, clip_far) when no layer contributes content.
|
|
31
|
-
*
|
|
32
|
-
* @param {Camera} c camera ECS component (its `object` is the THREE.Camera)
|
|
33
|
-
* @param {RenderLayerManager} layers
|
|
34
|
-
*/
|
|
35
|
-
export function auto_set_camera_clipping_planes(c, layers) {
|
|
36
|
-
const camera = c.object;
|
|
37
|
-
|
|
38
|
-
if (camera === null) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Capture the previous frame's tightened planes *before* overwriting them
|
|
43
|
-
// with the outer bounds below — the hysteresis further down compares the new
|
|
44
|
-
// range against them, so sampling after the overwrite would always measure
|
|
45
|
-
// against the full outer span and never let the planes tighten.
|
|
46
|
-
const old_near = camera.near;
|
|
47
|
-
const old_far = camera.far;
|
|
48
|
-
|
|
49
|
-
// Run visibility against the user-specified outer bounds, not the previous
|
|
50
|
-
// frame's tightened range — otherwise objects could be culled before we
|
|
51
|
-
// ever see them and the autoClip would shrink toward nothing.
|
|
52
|
-
camera.near = c.clip_near;
|
|
53
|
-
camera.far = c.clip_far;
|
|
54
|
-
|
|
55
|
-
frustum_from_camera(camera, scratch_three_frustum, true);
|
|
56
|
-
frustum3_planes_to_flat_from_three(scratch_three_frustum.planes, scratch_frustum_planes);
|
|
57
|
-
|
|
58
|
-
render_layers_compute_depth_range(
|
|
59
|
-
scratch_range,
|
|
60
|
-
layers,
|
|
61
|
-
scratch_frustum_planes,
|
|
62
|
-
camera.matrixWorld.elements
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
let new_near = scratch_range.near - CLIPPING_EPSILON;
|
|
66
|
-
let new_far = scratch_range.far + CLIPPING_EPSILON;
|
|
67
|
-
|
|
68
|
-
if (!isFinite(new_near) || new_near < CLIPPING_NEAR_MIN) {
|
|
69
|
-
new_near = CLIPPING_NEAR_MIN;
|
|
70
|
-
}
|
|
71
|
-
if (!isFinite(new_far) || new_far <= new_near) {
|
|
72
|
-
new_far = Math.max(new_near + CLIPPING_EPSILON, CLIPPING_FAR_DEFAULT);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Clamp inside the user-specified outer bounds so the tightened range
|
|
76
|
-
// never expands past what the camera is configured to render.
|
|
77
|
-
if (new_near < c.clip_near) {
|
|
78
|
-
new_near = c.clip_near;
|
|
79
|
-
}
|
|
80
|
-
if (new_far > c.clip_far) {
|
|
81
|
-
new_far = c.clip_far;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Hysteresis: only shrink each plane if the shrink is meaningful relative
|
|
85
|
-
// to the current span. Loosening always applies immediately.
|
|
86
|
-
const old_span = old_far - old_near;
|
|
87
|
-
const shrink_threshold = HYSTERESIS * old_span;
|
|
88
|
-
|
|
89
|
-
if (new_near > old_near && new_near - old_near < shrink_threshold) {
|
|
90
|
-
new_near = old_near;
|
|
91
|
-
}
|
|
92
|
-
if (new_far < old_far && old_far - new_far < shrink_threshold) {
|
|
93
|
-
new_far = old_far;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
camera.near = new_near;
|
|
97
|
-
camera.far = new_far;
|
|
98
|
-
|
|
99
|
-
// Rebuild the projection matrix from the tightened range — CameraView
|
|
100
|
-
// reads camera.projectionMatrix directly when capturing the frame's
|
|
101
|
-
// frustum, and the wide-range matrix from the depth-query step above is
|
|
102
|
-
// now stale.
|
|
103
|
-
camera.updateProjectionMatrix();
|
|
104
|
-
}
|
|
105
|
-
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {Camera} component
|
|
4
|
-
* @returns {THREE.PerspectiveCamera| THREE.OrthographicCamera}
|
|
5
|
-
*/
|
|
6
|
-
export function build_three_camera_object(component: Camera): THREE.PerspectiveCamera | THREE.OrthographicCamera;
|
|
7
|
-
//# sourceMappingURL=build_three_camera_object.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build_three_camera_object.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/build_three_camera_object.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,8DAFa,MAAM,iBAAiB,GAAE,MAAM,kBAAkB,CAsB7D"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { OrthographicCamera as ThreeOrthographicCamera, PerspectiveCamera as ThreePerspectiveCamera } from "three";
|
|
2
|
-
import { ProjectionType } from "./ProjectionType.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {Camera} component
|
|
7
|
-
* @returns {THREE.PerspectiveCamera| THREE.OrthographicCamera}
|
|
8
|
-
*/
|
|
9
|
-
export function build_three_camera_object(component) {
|
|
10
|
-
|
|
11
|
-
let result;
|
|
12
|
-
switch (component.projectionType.getValue()) {
|
|
13
|
-
default:
|
|
14
|
-
console.error(`Unsupported camera projection type "${component.projectionType.getValue()}", defaulting to perspective projection`);
|
|
15
|
-
//fallthrough
|
|
16
|
-
case ProjectionType.Perspective:
|
|
17
|
-
result = new ThreePerspectiveCamera(component.fov.getValue(), 1, 1, 50);
|
|
18
|
-
break;
|
|
19
|
-
case ProjectionType.Orthographic:
|
|
20
|
-
result = new ThreeOrthographicCamera(-10, 10, 20, -20, 1, 1);
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
result.far = component.clip_far;
|
|
26
|
-
result.near = component.clip_near;
|
|
27
|
-
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {Camera|ThreePerspectiveCamera} camera Three.js camera object
|
|
4
|
-
* @param {Frustum|THREE.Frustum|ThreeFrustum} result Three.js frustum object
|
|
5
|
-
* @param update_projection
|
|
6
|
-
*/
|
|
7
|
-
export function frustum_from_camera(camera: Camera | ThreePerspectiveCamera, result: Frustum | THREE.Frustum | ThreeFrustum, update_projection?: boolean): void;
|
|
8
|
-
//# sourceMappingURL=frustum_from_camera.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frustum_from_camera.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/frustum_from_camera.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,4CAJW,+BAA6B,UAC7B,UAAQ,MAAM,OAAO,eAAa,qCAY5C"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Matrix4 } from "three";
|
|
2
|
-
|
|
3
|
-
const matrix4 = new Matrix4();
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {Camera|ThreePerspectiveCamera} camera Three.js camera object
|
|
8
|
-
* @param {Frustum|THREE.Frustum|ThreeFrustum} result Three.js frustum object
|
|
9
|
-
* @param update_projection
|
|
10
|
-
*/
|
|
11
|
-
export function frustum_from_camera(camera, result, update_projection = true) {
|
|
12
|
-
if (update_projection) {
|
|
13
|
-
camera.updateProjectionMatrix();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// construct view projection matrix
|
|
17
|
-
matrix4.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
18
|
-
|
|
19
|
-
result.setFromProjectionMatrix(matrix4);
|
|
20
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {Camera} camera
|
|
4
|
-
* @param {number} width
|
|
5
|
-
* @param {number} height
|
|
6
|
-
*/
|
|
7
|
-
export function set_camera_aspect_ratio(camera: Camera, width: number, height: number): void;
|
|
8
|
-
import { Camera } from "./Camera.js";
|
|
9
|
-
//# sourceMappingURL=set_camera_aspect_ratio.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"set_camera_aspect_ratio.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/set_camera_aspect_ratio.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,gDAJW,MAAM,SACN,MAAM,UACN,MAAM,QAuChB;uBA7CsB,aAAa"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Camera } from "./Camera.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {Camera} camera
|
|
6
|
-
* @param {number} width
|
|
7
|
-
* @param {number} height
|
|
8
|
-
*/
|
|
9
|
-
export function set_camera_aspect_ratio(camera, width, height) {
|
|
10
|
-
const c = camera.object;
|
|
11
|
-
|
|
12
|
-
if (c === null) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const aspect = width / height;
|
|
17
|
-
|
|
18
|
-
switch (camera.projectionType.getValue()) {
|
|
19
|
-
case Camera.ProjectionType.Perspective:
|
|
20
|
-
c.aspect = aspect;
|
|
21
|
-
break;
|
|
22
|
-
case Camera.ProjectionType.Orthographic:
|
|
23
|
-
//use smaller values to get a bit of a "zoom" on the world
|
|
24
|
-
const w = c.right - c.left;
|
|
25
|
-
const h = c.top - c.bottom;
|
|
26
|
-
|
|
27
|
-
const existingAspect = w / h;
|
|
28
|
-
|
|
29
|
-
const aspectDelta = aspect - existingAspect;
|
|
30
|
-
|
|
31
|
-
if (aspectDelta > 0) {
|
|
32
|
-
const d = h * aspectDelta;
|
|
33
|
-
c.left -= d / 2;
|
|
34
|
-
c.right += d / 2;
|
|
35
|
-
} else if (aspectDelta < 0) {
|
|
36
|
-
const d = -h * aspectDelta;
|
|
37
|
-
|
|
38
|
-
c.top += d / 2;
|
|
39
|
-
c.bottom -= d / 2;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
c.updateProjectionMatrix();
|
|
46
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {Vector3} result
|
|
4
|
-
* @param {Vector3} input
|
|
5
|
-
* @param {number[]} projection_matrix_inverse inverse of projection matrix
|
|
6
|
-
* @param {number[]} world_matrix world transform
|
|
7
|
-
*/
|
|
8
|
-
export function unprojectPoint(result: Vector3, input: Vector3, projection_matrix_inverse: number[], world_matrix: number[]): void;
|
|
9
|
-
//# sourceMappingURL=unprojectPoint.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unprojectPoint.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/unprojectPoint.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,2FAHW,MAAM,EAAE,gBACR,MAAM,EAAE,QAMlB"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {Vector3} result
|
|
6
|
-
* @param {Vector3} input
|
|
7
|
-
* @param {number[]} projection_matrix_inverse inverse of projection matrix
|
|
8
|
-
* @param {number[]} world_matrix world transform
|
|
9
|
-
*/
|
|
10
|
-
export function unprojectPoint(result, input, projection_matrix_inverse, world_matrix) {
|
|
11
|
-
result.copy(input);
|
|
12
|
-
result.applyMatrix4(projection_matrix_inverse);
|
|
13
|
-
result.applyMatrix4(world_matrix);
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update_camera_transform.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/update_camera_transform.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,8DAUC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { threeUpdateTransform } from "../../util/threeUpdateTransform.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {Camera} camera
|
|
6
|
-
*/
|
|
7
|
-
export function update_camera_transform(camera) {
|
|
8
|
-
|
|
9
|
-
const three_camera = camera.object;
|
|
10
|
-
|
|
11
|
-
if (three_camera === null) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
three_camera.updateProjectionMatrix();
|
|
16
|
-
threeUpdateTransform(three_camera);
|
|
17
|
-
}
|