@woosh/meep-engine 2.39.1 → 2.39.4

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.
Files changed (49) hide show
  1. package/core/bvh2/{traversal/__detailed_box_volume_intersection.js → aabb3/aabb3_detailed_volume_intersection.js} +47 -27
  2. package/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +13 -0
  3. package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -3
  4. package/core/bvh2/traversal/__process_point_if_within_planes.js +1 -0
  5. package/core/bvh2/traversal/aabb3_detailed_volume_intersection_callback_based.js +60 -0
  6. package/core/geom/3d/plane/is_point_within_planes.js +46 -0
  7. package/core/geom/Vector3.d.ts +8 -0
  8. package/editor/actions/concrete/ActionUpdateTexture.js +21 -0
  9. package/editor/actions/concrete/ArrayCopyAction.js +39 -0
  10. package/editor/actions/concrete/ModifyPatchTextureArray2DAction.js +182 -0
  11. package/editor/enableEditor.js +30 -2
  12. package/editor/tools/paint/TerrainPaintTool.js +19 -3
  13. package/editor/tools/paint/TerrainTexturePaintTool.js +19 -57
  14. package/editor/tools/paint/prototypeTerrainEditor.js +67 -0
  15. package/editor/view/ecs/ComponentControlView.js +105 -10
  16. package/editor/view/ecs/EntityEditor.js +1 -1
  17. package/engine/ecs/fow/FogOfWarSystem.js +6 -3
  18. package/engine/ecs/terrain/ecs/Terrain.js +57 -47
  19. package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +16 -2
  20. package/engine/ecs/terrain/ecs/layers/TerrainLayers.js +17 -0
  21. package/engine/ecs/terrain/ecs/splat/SplatMapping.js +24 -78
  22. package/engine/ecs/terrain/ecs/splat/loadLegacyTerrainSplats.js +73 -0
  23. package/engine/graphics/camera/camera_compute_distance_to_fit_length.d.ts +1 -0
  24. package/engine/graphics/camera/camera_compute_distance_to_fit_length.js +16 -0
  25. package/engine/graphics/camera/testClippingPlaneComputation.js +7 -4
  26. package/engine/graphics/ecs/camera/Camera.js +2 -2
  27. package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +5 -8
  28. package/engine/graphics/ecs/camera/CameraSystem.js +18 -184
  29. package/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.js +32 -0
  30. package/engine/graphics/ecs/camera/build_three_camera_object.js +29 -0
  31. package/engine/graphics/ecs/camera/compute_perspective_camera_focal_position.js +27 -0
  32. package/engine/graphics/ecs/camera/frustum_from_camera.js +20 -0
  33. package/engine/graphics/ecs/camera/is_valid_distance_value.js +11 -0
  34. package/engine/graphics/ecs/camera/set_camera_aspect_ratio.js +46 -0
  35. package/engine/graphics/ecs/camera/update_camera_transform.js +17 -0
  36. package/engine/graphics/ecs/path/testPathDisplaySystem.js +19 -15
  37. package/engine/graphics/ecs/path/tube/StandardMaterialDefinition.js +9 -0
  38. package/engine/graphics/ecs/path/tube/TubePathStyle.js +9 -0
  39. package/engine/graphics/{Utils.js → makeModelView.js} +1 -10
  40. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +2 -2
  41. package/engine/graphics/render/forward_plus/LightManager.js +2 -2
  42. package/engine/graphics/render/view/CameraView.js +2 -2
  43. package/engine/graphics/texture/sampler/Sampler2D.js +1293 -1267
  44. package/engine/graphics/texture/texture_array_2d_copy.js +45 -0
  45. package/engine/graphics/util/makeMeshPreviewScene.js +2 -2
  46. package/package.json +1 -1
  47. package/view/renderModel.js +1 -1
  48. package/view/string_tag_to_css_class_name.js +12 -0
  49. package/engine/graphics/util/computeMeshPreviewCameraDistance.js +0 -10
@@ -0,0 +1,27 @@
1
+ import { Vector3 as ThreeVector3 } from "three";
2
+
3
+ /**
4
+ * Compute position of focal point of the camera in world coordinate space. This is the "pinhole" where all perspective lines meet.
5
+ * @param {THREE.PerspectiveCamera} camera
6
+ * @param {Vector3} result
7
+ */
8
+ export function compute_perspective_camera_focal_position(camera, result) {
9
+ if (camera.isPerspectiveCamera !== true) {
10
+ throw new TypeError('expected a perspective camera, got something else');
11
+ }
12
+
13
+ const focalLength = camera.getFocalLength();
14
+
15
+ const v3 = new ThreeVector3(0, 0, 0.5);
16
+
17
+ v3.unproject(camera);
18
+ //get direction
19
+ v3.sub(camera.position).normalize();
20
+
21
+ //
22
+ v3.multiplyScalar(-focalLength);
23
+
24
+ v3.add(camera.position);
25
+
26
+ result.set(v3.x, v3.y, v3.z);
27
+ }
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * @param {number} value
4
+ * @returns {boolean}
5
+ */
6
+ export function is_valid_distance_value(value) {
7
+ return value !== Number.NEGATIVE_INFINITY
8
+ && value !== Number.POSITIVE_INFINITY
9
+ && !Number.isNaN(value)
10
+ ;
11
+ }
@@ -0,0 +1,46 @@
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.bottom - c.top;
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
+ }
@@ -0,0 +1,17 @@
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
+ }
@@ -68,6 +68,9 @@ import { PathDisplayHighlightSystem } from "./highlight/PathDisplayHighlightSyst
68
68
  import { ShadedGeometryHighlightSystem } from "../highlight/system/ShadedGeometryHighlightSystem.js";
69
69
  import { BasicMaterialDefinition } from "./tube/BasicMaterialDefinition.js";
70
70
 
71
+ import '../../../../../../../css/game.scss';
72
+ import { GizmoRenderingPlugin } from "../../render/gizmo/GizmoRenderingPlugin.js";
73
+
71
74
  const engineHarness = new EngineHarness();
72
75
 
73
76
  function makeConfig(engine) {
@@ -126,7 +129,8 @@ function makeConfig(engine) {
126
129
 
127
130
  // Plugins
128
131
 
129
- config.addPlugin(AmbientOcclusionPostProcessEffect)
132
+ config.addPlugin(AmbientOcclusionPostProcessEffect);
133
+ config.addPlugin(GizmoRenderingPlugin);
130
134
 
131
135
  // Knowledge
132
136
 
@@ -322,9 +326,9 @@ function sample_style_tube() {
322
326
  style.color.setHSV(0, 1, 0.9);
323
327
  }
324
328
 
325
- function make_basic(style){
329
+ function make_basic(style) {
326
330
  style.material_type = TubeMaterialType.Basic;
327
- style.material = new BasicMaterialDefinition();
331
+ style.material = new BasicMaterialDefinition();
328
332
 
329
333
  style.color.setHSV(0, 1, 0.9);
330
334
  }
@@ -350,23 +354,23 @@ function sample_style_tube() {
350
354
  // -0.1, -0.5,
351
355
  // ];
352
356
 
353
- // style.shape = [
354
- // -0.5, -0.1,
355
- // 0.5, -0.1,
356
- // 0.5, 0.1,
357
- // -0.5, 0.1,
358
- // ];
359
- //
360
357
  style.shape = [
361
358
  -0.5, -0.1,
362
- -0.45, -0.15,
363
- 0.45, -0.15,
364
359
  0.5, -0.1,
365
360
  0.5, 0.1,
366
- 0.45, 0.15,
367
- -0.45, 0.15,
368
- -0.5, 0.1
361
+ -0.5, 0.1,
369
362
  ];
363
+ //
364
+ // style.shape = [
365
+ // -0.5, -0.1,
366
+ // -0.45, -0.15,
367
+ // 0.45, -0.15,
368
+ // 0.5, -0.1,
369
+ // 0.5, 0.1,
370
+ // 0.45, 0.15,
371
+ // -0.45, 0.15,
372
+ // -0.5, 0.1
373
+ // ];
370
374
 
371
375
  style.path_mask = [
372
376
  0, 1
@@ -3,4 +3,13 @@ export class StandardMaterialDefinition {
3
3
  this.metalness = 0;
4
4
  this.roughness = 1;
5
5
  }
6
+
7
+ fromJSON({
8
+ roughness = 1,
9
+ metalness = 0
10
+ }) {
11
+
12
+ this.roughness = roughness;
13
+ this.metalness = metalness;
14
+ }
6
15
  }
@@ -3,6 +3,8 @@ import { TubeMaterialType } from "./TubeMaterialType.js";
3
3
  import { assert } from "../../../../../core/assert.js";
4
4
  import { MatcapMaterialDefinition } from "./MatcapMaterialDefinition.js";
5
5
  import { CapType } from "./CapType.js";
6
+ import { StandardMaterialDefinition } from "./StandardMaterialDefinition.js";
7
+ import { BasicMaterialDefinition } from "./BasicMaterialDefinition.js";
6
8
 
7
9
  const DEFAULT_COLOR = Object.freeze({ r: 1, g: 1, b: 1 });
8
10
 
@@ -135,6 +137,7 @@ export class TubePathStyle {
135
137
  assert.enum(cap_type, CapType, 'cap_type');
136
138
 
137
139
  if (shape === undefined) {
140
+ // legacy API, using circle
138
141
  assert.isNumber(radial_resolution, 'radial_resolution');
139
142
 
140
143
  shape = build_circle_shape(radial_resolution);
@@ -163,6 +166,12 @@ export class TubePathStyle {
163
166
  case TubeMaterialType.Matcap:
164
167
  this.material = new MatcapMaterialDefinition();
165
168
  break;
169
+ case TubeMaterialType.Standard:
170
+ this.material = new StandardMaterialDefinition();
171
+ break;
172
+ case TubeMaterialType.Basic:
173
+ this.material = new BasicMaterialDefinition();
174
+ break;
166
175
  default:
167
176
  throw new Error(`Unsupported material type '${material_type}'`);
168
177
  }
@@ -1,10 +1,6 @@
1
- /**
2
- * Created by Alex on 09/03/2016.
3
- */
4
1
  import { Sampler2D } from "./texture/sampler/Sampler2D.js";
5
2
  import { renderObjectToSampler2D } from "./util/renderObjectToSampler2D.js";
6
3
 
7
-
8
4
  /**
9
5
  *
10
6
  * @param {{create:function():Object3D}} asset
@@ -13,7 +9,7 @@ import { renderObjectToSampler2D } from "./util/renderObjectToSampler2D.js";
13
9
  * @param {AABB2} focus
14
10
  * @returns {{domElement: HTMLCanvasElement, pixels: Uint8Array, graphics, camera: PerspectiveCamera, render: Function, dispose:Function, mesh, scene: Scene}}
15
11
  */
16
- function makeModelView(asset, size, renderer, focus) {
12
+ export function makeModelView(asset, size, renderer, focus) {
17
13
  const mesh = asset.create();
18
14
 
19
15
  const canvas = document.createElement("canvas");
@@ -49,8 +45,3 @@ function makeModelView(asset, size, renderer, focus) {
49
45
  dispose: proxy_renderer.dispose
50
46
  };
51
47
  }
52
-
53
-
54
- export {
55
- makeModelView
56
- };
@@ -4,7 +4,6 @@ import { lerp } from "../../../../../../core/math/lerp.js";
4
4
  import { max2 } from "../../../../../../core/math/max2.js";
5
5
  import { min2 } from "../../../../../../core/math/min2.js";
6
6
  import { Box3, BufferGeometry, Frustum, Matrix4, Points, PointsMaterial } from 'three';
7
- import { frustumFromCamera } from "../../../../ecs/camera/CameraSystem.js";
8
7
  import { ParticlePool } from "./ParticlePool.js";
9
8
  import { ParticleParameter } from "../parameter/ParticleParameter.js";
10
9
  import { ParameterSet } from "../parameter/ParameterSet.js";
@@ -35,6 +34,7 @@ import { distance_to_camera } from "./distance_to_camera.js";
35
34
  import { computeEmissionFunction } from "./computeEmissionFunction.js";
36
35
  import { PARTICULAR_PARTICLE_SPECIFICATION } from "./PARTICULAR_PARTICLE_SPECIFICATION.js";
37
36
  import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
37
+ import { frustum_from_camera } from "../../../../ecs/camera/frustum_from_camera.js";
38
38
 
39
39
  const EMPTY_GEOMETRY = new BufferGeometry();
40
40
 
@@ -745,7 +745,7 @@ export class ParticleEmitter {
745
745
  //assert.notOk(this.particles.hasHoles(), 'Broken pre-condition: particle pool must not have holes. Make sure to call "compact" before sorting');
746
746
 
747
747
  //get font plane of camera
748
- frustumFromCamera(camera, frustum);
748
+ frustum_from_camera(camera, frustum);
749
749
  const nearPlane = frustum.planes[0];
750
750
  const nearPlaneNormal = nearPlane.normal;
751
751
 
@@ -13,7 +13,6 @@ import {
13
13
  UnsignedByteType,
14
14
  UnsignedShortType
15
15
  } from "three";
16
- import { frustumFromCamera } from "../../ecs/camera/CameraSystem.js";
17
16
  import Vector3 from "../../../../core/geom/Vector3.js";
18
17
  import { query_bvh_frustum_from_objects } from "./query/query_bvh_frustum_from_objects.js";
19
18
  import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
@@ -47,6 +46,7 @@ import { v3_distance } from "../../../../core/geom/v3_distance.js";
47
46
  import { array_copy } from "../../../../core/collection/array/copyArray.js";
48
47
  import { arrayQuickSort } from "../../../../core/collection/array/arrayQuickSort.js";
49
48
  import { invokeObjectCompare } from "../../../../core/model/object/invokeObjectCompare.js";
49
+ import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
50
50
 
51
51
  const LOOKUP_CACHE_SIZE = 1024; // must be power of two
52
52
 
@@ -592,7 +592,7 @@ export class LightManager {
592
592
  * @private
593
593
  */
594
594
  __build_view_frustum(camera) {
595
- frustumFromCamera(camera, this.__view_frustum);
595
+ frustum_from_camera(camera, this.__view_frustum);
596
596
 
597
597
  arraySwapElements(this.__view_frustum.planes, 4, 5);
598
598
 
@@ -1,11 +1,11 @@
1
1
  import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
2
2
  import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
3
3
  import { CameraViewFlags } from "./CameraViewFlags.js";
4
- import { frustumFromCamera } from "../../ecs/camera/CameraSystem.js";
5
4
  import { Frustum } from "three";
6
5
  import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
7
6
  import Signal from "../../../../core/events/signal/Signal.js";
8
7
  import { compare_three_objects } from "../../three/compare_three_objects.js";
8
+ import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
9
9
 
10
10
  const DEFAULT_FLAGS = CameraViewFlags.Active
11
11
  | CameraViewFlags.AdaptivePlaneNear
@@ -76,7 +76,7 @@ export class CameraView {
76
76
  this.__camera = camera;
77
77
 
78
78
  // read frustum
79
- frustumFromCamera(camera, scratch_frustum, false);
79
+ frustum_from_camera(camera, scratch_frustum, false);
80
80
 
81
81
  // update view definition
82
82
  read_frustum_planes_to_array(scratch_frustum.planes, this.frustum);