@woosh/meep-engine 2.39.23 → 2.39.27

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.
@@ -69,7 +69,7 @@ async function main(engine) {
69
69
 
70
70
  editor_controls.enable();
71
71
 
72
- const camera_orientation_gizmo = new BlenderCameraOrientationGizmo(new Quaternion());
72
+ const camera_orientation_gizmo = new BlenderCameraOrientationGizmo();
73
73
 
74
74
  camera_orientation_gizmo.css({
75
75
  position: 'absolute',
@@ -3,11 +3,44 @@ import Quaternion from "../../../core/geom/Quaternion";
3
3
  import Signal from "../../../core/events/signal/Signal";
4
4
 
5
5
  interface ISignals extends IViewSignals {
6
- readonly axisSelected: Signal
6
+ readonly axisSelected: Signal<string>
7
+ }
8
+
9
+ interface IDirectionStyle {
10
+ near_fill?: string
11
+ near_stroke_width?: number
12
+ near_stroke_color?: string
13
+
14
+ far_fill?: string
15
+ far_stroke_width?: number
16
+ far_stroke_color?: string
17
+ }
18
+
19
+ interface IOptions {
20
+ size?: number,
21
+ padding?: number,
22
+ bubbleSizePrimary?: number,
23
+ bubbleSizeSecondary?: number,
24
+ lineWidth?: number,
25
+ fontSize?: string,
26
+ fontFamily?: string,
27
+ fontWeight?: string,
28
+ fontColor?: string,
29
+ fontYAdjust?: number,
30
+ selectionFontColor?: string,
31
+ axisStyles?: {
32
+ px?: IDirectionStyle,
33
+ py?: IDirectionStyle,
34
+ pz?: IDirectionStyle,
35
+
36
+ nx?: IDirectionStyle,
37
+ ny?: IDirectionStyle,
38
+ nz?: IDirectionStyle,
39
+ }
7
40
  }
8
41
 
9
42
  export class BlenderCameraOrientationGizmo extends View {
10
- constructor(orientation?: Quaternion)
43
+ constructor(options?: IOptions)
11
44
 
12
45
  on: ISignals
13
46
 
@@ -57,6 +57,30 @@ class DirectionStyle {
57
57
  }
58
58
  }
59
59
 
60
+ function apply_hierarchical_options(source, target) {
61
+ for (const prop_name in source) {
62
+ if (!target.hasOwnProperty(prop_name)) {
63
+ console.warn(`Property '${prop_name}' doesn't exist, valid properties are : ${Object.keys(target)}`);
64
+ continue;
65
+ }
66
+
67
+ const existing_target_value = target[prop_name];
68
+ const source_value = source[prop_name];
69
+
70
+ if (typeof existing_target_value === "object") {
71
+ if (typeof existing_target_value.fromJSON === "function") {
72
+ existing_target_value.fromJSON(source_value);
73
+ } else {
74
+ apply_hierarchical_options(source_value, existing_target_value);
75
+ }
76
+ } else {
77
+ target[prop_name] = source_value;
78
+ }
79
+
80
+
81
+ }
82
+ }
83
+
60
84
 
61
85
  /**
62
86
  * Modelled on https://github.com/jrj2211/three-orientation-gizmo/blob/master/src/OrientationGizmo.js
@@ -64,16 +88,15 @@ class DirectionStyle {
64
88
  export class BlenderCameraOrientationGizmo extends CanvasView {
65
89
  /**
66
90
  *
67
- * @param {Quaternion} quaternion
68
91
  */
69
- constructor(quaternion = null) {
92
+ constructor(options = {}) {
70
93
  super();
71
94
 
72
95
  /**
73
96
  *
74
97
  * @type {Quaternion}
75
98
  */
76
- this.orientation = quaternion;
99
+ this.orientation = null;
77
100
 
78
101
  this.options = {
79
102
  size: 100,
@@ -129,6 +152,9 @@ export class BlenderCameraOrientationGizmo extends CanvasView {
129
152
  }
130
153
  };
131
154
 
155
+ // read options
156
+ apply_hierarchical_options(options, this.options);
157
+
132
158
  // Generate list of axes
133
159
  this.bubbles = [
134
160
  {
@@ -312,7 +338,7 @@ export class BlenderCameraOrientationGizmo extends CanvasView {
312
338
  compose_matrix4_array(rotation_matrix, Vector3.zero, rotation, Vector3.one);
313
339
  mat4.invert(rotation_matrix, rotation_matrix);
314
340
 
315
- for (let bubble of this.bubbles) {
341
+ for (const bubble of this.bubbles) {
316
342
  const direction = bubble.direction.clone();
317
343
  direction.applyMatrix4(rotation_matrix);
318
344
 
@@ -321,10 +347,12 @@ export class BlenderCameraOrientationGizmo extends CanvasView {
321
347
 
322
348
  // Generate a list of layers to draw
323
349
  const layers = [];
324
- for (let axis in this.bubbles) {
350
+
351
+ for (const bubble of this.bubbles) {
325
352
  // Check if the name starts with a negative and dont add it to the layer list if secondary axis is turned off
326
- if (this.options.showSecondary === true || axis[0] !== "-") {
327
- layers.push(this.bubbles[axis]);
353
+ const is_secondary = bubble.axis[0] !== "-";
354
+ if (this.options.showSecondary === true || is_secondary) {
355
+ layers.push(bubble);
328
356
  }
329
357
  }
330
358
 
@@ -1,4 +1,4 @@
1
- import {Camera, PerspectiveCamera, Scene, WebGLRenderer, WebGLRenderTarget} from "three";
1
+ import {PerspectiveCamera, Scene, WebGLRenderer, WebGLRenderTarget} from "three";
2
2
  import {RenderLayerManager} from "./render/layers/RenderLayerManager";
3
3
  import Vector3 from "../../core/geom/Vector3";
4
4
  import Vector2 from "../../core/geom/Vector2";
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.39.23",
8
+ "version": "2.39.27",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",