lythreeframe 1.2.8 → 1.2.9

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.
@@ -3164,6 +3164,19 @@ class FirstPerson extends Pawn {
3164
3164
  }
3165
3165
  }
3166
3166
 
3167
+ function debounce(func, delay) {
3168
+ let timeoutId = null;
3169
+ return (...args) => {
3170
+ if (timeoutId) {
3171
+ clearTimeout(timeoutId);
3172
+ }
3173
+ timeoutId = setTimeout(() => {
3174
+ func(...args);
3175
+ timeoutId = null;
3176
+ }, delay);
3177
+ };
3178
+ }
3179
+
3167
3180
  class TransformGizmo extends Pawn {
3168
3181
  get control() {
3169
3182
  if (!this._control) {
@@ -3241,26 +3254,29 @@ class TransformGizmo extends Pawn {
3241
3254
  }
3242
3255
  }
3243
3256
  onObjectChanged() {
3244
- if (this.primaryTarget) {
3245
- //const TA1 = this.primaryTarget.getMatrixInWorld();
3246
- this.helperObject.updateMatrixWorld(true);
3247
- const TA2 = this.helperObject.matrixWorld.clone();
3248
- this.primaryTarget.onTransforming(TA2);
3249
- // const TA1Inverse = TA1.clone().invert();
3250
- //const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
3251
- this.targets.forEach((tar) => {
3252
- if (tar !== this.primaryTarget) {
3253
- let t = this.targetMatrixMap.get(tar);
3254
- if (t) {
3255
- let TB2 = new webgpu.Matrix4().multiplyMatrices(TA2, t); // B
3256
- tar.onTransforming(TB2);
3257
+ const de = debounce(() => {
3258
+ if (this.primaryTarget) {
3259
+ //const TA1 = this.primaryTarget.getMatrixInWorld();
3260
+ this.helperObject.updateMatrixWorld(true);
3261
+ const TA2 = this.helperObject.matrixWorld.clone();
3262
+ this.primaryTarget.onTransforming(TA2);
3263
+ // const TA1Inverse = TA1.clone().invert();
3264
+ //const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
3265
+ this.targets.forEach((tar) => {
3266
+ if (tar !== this.primaryTarget) {
3267
+ let t = this.targetMatrixMap.get(tar);
3268
+ if (t) {
3269
+ let TB2 = new webgpu.Matrix4().multiplyMatrices(TA2, t); // B
3270
+ tar.onTransforming(TB2);
3271
+ }
3257
3272
  }
3258
- }
3259
- });
3260
- }
3261
- if (this.onUpdateFunction) {
3262
- this.onUpdateFunction();
3263
- }
3273
+ });
3274
+ }
3275
+ if (this.onUpdateFunction) {
3276
+ this.onUpdateFunction();
3277
+ }
3278
+ }, 100);
3279
+ de();
3264
3280
  }
3265
3281
  set enable(newEnable) {
3266
3282
  this.control.enabled = newEnable;
@@ -3162,6 +3162,19 @@ class FirstPerson extends Pawn {
3162
3162
  }
3163
3163
  }
3164
3164
 
3165
+ function debounce(func, delay) {
3166
+ let timeoutId = null;
3167
+ return (...args) => {
3168
+ if (timeoutId) {
3169
+ clearTimeout(timeoutId);
3170
+ }
3171
+ timeoutId = setTimeout(() => {
3172
+ func(...args);
3173
+ timeoutId = null;
3174
+ }, delay);
3175
+ };
3176
+ }
3177
+
3165
3178
  class TransformGizmo extends Pawn {
3166
3179
  get control() {
3167
3180
  if (!this._control) {
@@ -3239,26 +3252,29 @@ class TransformGizmo extends Pawn {
3239
3252
  }
3240
3253
  }
3241
3254
  onObjectChanged() {
3242
- if (this.primaryTarget) {
3243
- //const TA1 = this.primaryTarget.getMatrixInWorld();
3244
- this.helperObject.updateMatrixWorld(true);
3245
- const TA2 = this.helperObject.matrixWorld.clone();
3246
- this.primaryTarget.onTransforming(TA2);
3247
- // const TA1Inverse = TA1.clone().invert();
3248
- //const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
3249
- this.targets.forEach((tar) => {
3250
- if (tar !== this.primaryTarget) {
3251
- let t = this.targetMatrixMap.get(tar);
3252
- if (t) {
3253
- let TB2 = new Matrix4().multiplyMatrices(TA2, t); // B
3254
- tar.onTransforming(TB2);
3255
+ const de = debounce(() => {
3256
+ if (this.primaryTarget) {
3257
+ //const TA1 = this.primaryTarget.getMatrixInWorld();
3258
+ this.helperObject.updateMatrixWorld(true);
3259
+ const TA2 = this.helperObject.matrixWorld.clone();
3260
+ this.primaryTarget.onTransforming(TA2);
3261
+ // const TA1Inverse = TA1.clone().invert();
3262
+ //const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
3263
+ this.targets.forEach((tar) => {
3264
+ if (tar !== this.primaryTarget) {
3265
+ let t = this.targetMatrixMap.get(tar);
3266
+ if (t) {
3267
+ let TB2 = new Matrix4().multiplyMatrices(TA2, t); // B
3268
+ tar.onTransforming(TB2);
3269
+ }
3255
3270
  }
3256
- }
3257
- });
3258
- }
3259
- if (this.onUpdateFunction) {
3260
- this.onUpdateFunction();
3261
- }
3271
+ });
3272
+ }
3273
+ if (this.onUpdateFunction) {
3274
+ this.onUpdateFunction();
3275
+ }
3276
+ }, 100);
3277
+ de();
3262
3278
  }
3263
3279
  set enable(newEnable) {
3264
3280
  this.control.enabled = newEnable;
@@ -0,0 +1 @@
1
+ export declare function debounce<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",