lythreeframe 1.0.52 → 1.1.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.
@@ -1721,6 +1721,17 @@ class Viewport {
1721
1721
  this.markRenderStateDirty();
1722
1722
  }
1723
1723
  }
1724
+ setOutlineObjects(objects) {
1725
+ this.outlineObjects.length = 0;
1726
+ this.outlineObjects.push(...objects);
1727
+ if (!this.postProcessParam.outline) {
1728
+ this.postProcessParam.outline = DefaultOutlineParams;
1729
+ this.setupPostProcess();
1730
+ }
1731
+ else {
1732
+ this.markRenderStateDirty();
1733
+ }
1734
+ }
1724
1735
  removeOutlineObject(obj) {
1725
1736
  if (!this.postProcessParam.outline) {
1726
1737
  this.outlineObjects = [];
@@ -3020,9 +3031,13 @@ class TransformGizmo extends Pawn {
3020
3031
  this.onDraggingChangedEvent = (param) => { this.onDraggingChanged(param); };
3021
3032
  this.onObjectChangeEvent = () => { this.onObjectChanged(); };
3022
3033
  this.onChangeEvent = () => { this.onChange(); };
3023
- this.onUpdateFunctions = [];
3024
- this.onDraggingFunctions = [];
3025
- this._control = new TransformControls_js.TransformControls(controller.camera, controller.viewPort.canvas);
3034
+ this.onUpdateFunction = null;
3035
+ this.onDraggingFunction = null;
3036
+ let canvas = controller.viewPort.canvas;
3037
+ if (!canvas) {
3038
+ throw new Error("TransformGizmo:Canvas not found");
3039
+ }
3040
+ this._control = new TransformControls_js.TransformControls(controller.camera, canvas);
3026
3041
  this.control.getHelper().traverse((elem) => {
3027
3042
  elem.userData["rayIgnored"] = true;
3028
3043
  });
@@ -3071,9 +3086,9 @@ class TransformGizmo extends Pawn {
3071
3086
  let tMatrix = this.primaryTarget.getMatrixInWorld();
3072
3087
  tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
3073
3088
  }
3074
- this.onDraggingFunctions.forEach((elem) => {
3075
- elem(event.value);
3076
- });
3089
+ if (this.onDraggingFunction) {
3090
+ this.onDraggingFunction(event.value);
3091
+ }
3077
3092
  }
3078
3093
  onObjectChanged() {
3079
3094
  if (this.primaryTarget) {
@@ -3093,9 +3108,9 @@ class TransformGizmo extends Pawn {
3093
3108
  }
3094
3109
  });
3095
3110
  }
3096
- this.onUpdateFunctions.forEach((elem) => {
3097
- elem();
3098
- });
3111
+ if (this.onUpdateFunction) {
3112
+ this.onUpdateFunction();
3113
+ }
3099
3114
  }
3100
3115
  set enable(newEnable) {
3101
3116
  this.control.enabled = newEnable;
@@ -3115,13 +3130,10 @@ class TransformGizmo extends Pawn {
3115
3130
  this.targetMatrixMap.set(elem, TB_local);
3116
3131
  });
3117
3132
  if (onUpdate) {
3118
- this.onUpdateFunctions.push(onUpdate);
3119
- }
3120
- if (onUpdate) {
3121
- this.onUpdateFunctions.push(onUpdate);
3133
+ this.onUpdateFunction = onUpdate;
3122
3134
  }
3123
3135
  if (onDragging) {
3124
- this.onDraggingFunctions.push(onDragging);
3136
+ this.onDraggingFunction = onDragging;
3125
3137
  }
3126
3138
  this.isTickEnabled = true;
3127
3139
  }
@@ -3142,6 +3154,24 @@ class TransformGizmo extends Pawn {
3142
3154
  setSize(size) {
3143
3155
  this.control.setSize(size);
3144
3156
  }
3157
+ getTranslationSnap() {
3158
+ return this.control.translationSnap;
3159
+ }
3160
+ setTranslationSnap(translationSnap) {
3161
+ this.control.setTranslationSnap(translationSnap);
3162
+ }
3163
+ getRotationnSnap() {
3164
+ return this.control.rotationSnap;
3165
+ }
3166
+ setRotationSnap(translationSnap) {
3167
+ this.control.setRotationSnap(translationSnap);
3168
+ }
3169
+ getScaleSnap() {
3170
+ return this.control.scaleSnap;
3171
+ }
3172
+ setScaleSnap(translationSnap) {
3173
+ this.control.setScaleSnap(translationSnap);
3174
+ }
3145
3175
  destroy() {
3146
3176
  var _a;
3147
3177
  this.isTickEnabled = false;
@@ -3149,8 +3179,8 @@ class TransformGizmo extends Pawn {
3149
3179
  this.targetMatrixMap.clear();
3150
3180
  this.targets = [];
3151
3181
  this.primaryTarget = null;
3152
- this.onUpdateFunctions = [];
3153
- this.onDraggingFunctions = [];
3182
+ this.onUpdateFunction = null;
3183
+ this.onDraggingFunction = null;
3154
3184
  (_a = this._control) === null || _a === void 0 ? void 0 : _a.dispose();
3155
3185
  this._control = null;
3156
3186
  super.destroy();
@@ -1719,6 +1719,17 @@ class Viewport {
1719
1719
  this.markRenderStateDirty();
1720
1720
  }
1721
1721
  }
1722
+ setOutlineObjects(objects) {
1723
+ this.outlineObjects.length = 0;
1724
+ this.outlineObjects.push(...objects);
1725
+ if (!this.postProcessParam.outline) {
1726
+ this.postProcessParam.outline = DefaultOutlineParams;
1727
+ this.setupPostProcess();
1728
+ }
1729
+ else {
1730
+ this.markRenderStateDirty();
1731
+ }
1732
+ }
1722
1733
  removeOutlineObject(obj) {
1723
1734
  if (!this.postProcessParam.outline) {
1724
1735
  this.outlineObjects = [];
@@ -3018,9 +3029,13 @@ class TransformGizmo extends Pawn {
3018
3029
  this.onDraggingChangedEvent = (param) => { this.onDraggingChanged(param); };
3019
3030
  this.onObjectChangeEvent = () => { this.onObjectChanged(); };
3020
3031
  this.onChangeEvent = () => { this.onChange(); };
3021
- this.onUpdateFunctions = [];
3022
- this.onDraggingFunctions = [];
3023
- this._control = new TransformControls(controller.camera, controller.viewPort.canvas);
3032
+ this.onUpdateFunction = null;
3033
+ this.onDraggingFunction = null;
3034
+ let canvas = controller.viewPort.canvas;
3035
+ if (!canvas) {
3036
+ throw new Error("TransformGizmo:Canvas not found");
3037
+ }
3038
+ this._control = new TransformControls(controller.camera, canvas);
3024
3039
  this.control.getHelper().traverse((elem) => {
3025
3040
  elem.userData["rayIgnored"] = true;
3026
3041
  });
@@ -3069,9 +3084,9 @@ class TransformGizmo extends Pawn {
3069
3084
  let tMatrix = this.primaryTarget.getMatrixInWorld();
3070
3085
  tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
3071
3086
  }
3072
- this.onDraggingFunctions.forEach((elem) => {
3073
- elem(event.value);
3074
- });
3087
+ if (this.onDraggingFunction) {
3088
+ this.onDraggingFunction(event.value);
3089
+ }
3075
3090
  }
3076
3091
  onObjectChanged() {
3077
3092
  if (this.primaryTarget) {
@@ -3091,9 +3106,9 @@ class TransformGizmo extends Pawn {
3091
3106
  }
3092
3107
  });
3093
3108
  }
3094
- this.onUpdateFunctions.forEach((elem) => {
3095
- elem();
3096
- });
3109
+ if (this.onUpdateFunction) {
3110
+ this.onUpdateFunction();
3111
+ }
3097
3112
  }
3098
3113
  set enable(newEnable) {
3099
3114
  this.control.enabled = newEnable;
@@ -3113,13 +3128,10 @@ class TransformGizmo extends Pawn {
3113
3128
  this.targetMatrixMap.set(elem, TB_local);
3114
3129
  });
3115
3130
  if (onUpdate) {
3116
- this.onUpdateFunctions.push(onUpdate);
3117
- }
3118
- if (onUpdate) {
3119
- this.onUpdateFunctions.push(onUpdate);
3131
+ this.onUpdateFunction = onUpdate;
3120
3132
  }
3121
3133
  if (onDragging) {
3122
- this.onDraggingFunctions.push(onDragging);
3134
+ this.onDraggingFunction = onDragging;
3123
3135
  }
3124
3136
  this.isTickEnabled = true;
3125
3137
  }
@@ -3140,6 +3152,24 @@ class TransformGizmo extends Pawn {
3140
3152
  setSize(size) {
3141
3153
  this.control.setSize(size);
3142
3154
  }
3155
+ getTranslationSnap() {
3156
+ return this.control.translationSnap;
3157
+ }
3158
+ setTranslationSnap(translationSnap) {
3159
+ this.control.setTranslationSnap(translationSnap);
3160
+ }
3161
+ getRotationnSnap() {
3162
+ return this.control.rotationSnap;
3163
+ }
3164
+ setRotationSnap(translationSnap) {
3165
+ this.control.setRotationSnap(translationSnap);
3166
+ }
3167
+ getScaleSnap() {
3168
+ return this.control.scaleSnap;
3169
+ }
3170
+ setScaleSnap(translationSnap) {
3171
+ this.control.setScaleSnap(translationSnap);
3172
+ }
3143
3173
  destroy() {
3144
3174
  var _a;
3145
3175
  this.isTickEnabled = false;
@@ -3147,8 +3177,8 @@ class TransformGizmo extends Pawn {
3147
3177
  this.targetMatrixMap.clear();
3148
3178
  this.targets = [];
3149
3179
  this.primaryTarget = null;
3150
- this.onUpdateFunctions = [];
3151
- this.onDraggingFunctions = [];
3180
+ this.onUpdateFunction = null;
3181
+ this.onDraggingFunction = null;
3152
3182
  (_a = this._control) === null || _a === void 0 ? void 0 : _a.dispose();
3153
3183
  this._control = null;
3154
3184
  super.destroy();
@@ -42,6 +42,7 @@ export declare class Viewport {
42
42
  updateSSRParam(params: SSRParam | null): void;
43
43
  updateOutlineParam(params: OutlineParams | null): void;
44
44
  addOutlineObject(obj: Object3D): void;
45
+ setOutlineObjects(objects: Object3D[]): void;
45
46
  removeOutlineObject(obj: Object3D): void;
46
47
  destroyPostProcess(): void;
47
48
  onWindowResize(): void;
@@ -25,8 +25,8 @@ export declare class TransformGizmo extends Pawn {
25
25
  }) => void;
26
26
  protected onObjectChangeEvent: () => void;
27
27
  protected onChangeEvent: () => void;
28
- protected onUpdateFunctions: (() => void)[];
29
- protected onDraggingFunctions: ((event: any) => void)[];
28
+ protected onUpdateFunction: (() => void) | null;
29
+ protected onDraggingFunction: ((event: any) => void) | null;
30
30
  constructor(controller: Controller);
31
31
  possess(): void;
32
32
  unpossess(): void;
@@ -43,5 +43,11 @@ export declare class TransformGizmo extends Pawn {
43
43
  setSpace(space: "world" | "local"): void;
44
44
  setAxis(axis: "X" | "Y" | "Z" | "E" | "XY" | "YZ" | "XZ" | "XYZ" | "XYZE" | null): void;
45
45
  setSize(size: number): void;
46
+ getTranslationSnap(): number | null;
47
+ setTranslationSnap(translationSnap: number | null): void;
48
+ getRotationnSnap(): number | null;
49
+ setRotationSnap(translationSnap: number | null): void;
50
+ getScaleSnap(): number | null;
51
+ setScaleSnap(translationSnap: number | null): void;
46
52
  destroy(): void;
47
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.0.52",
3
+ "version": "1.1.1",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",