lythreeframe 1.2.7 → 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.
@@ -1872,6 +1872,9 @@ class Viewport {
1872
1872
  else { //console.log("render renderer");
1873
1873
  this.renderer.render(this.app.world.scene, this.app.camera);
1874
1874
  }
1875
+ if (this.labelRenderer) {
1876
+ this.labelRenderer.render(this.app.world.scene, this.app.camera);
1877
+ }
1875
1878
  this.isRenderStateDirty = false;
1876
1879
  }
1877
1880
  async renderAsImage(width = 1024, height = 1024) {
@@ -3161,6 +3164,19 @@ class FirstPerson extends Pawn {
3161
3164
  }
3162
3165
  }
3163
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
+
3164
3180
  class TransformGizmo extends Pawn {
3165
3181
  get control() {
3166
3182
  if (!this._control) {
@@ -3238,26 +3254,29 @@ class TransformGizmo extends Pawn {
3238
3254
  }
3239
3255
  }
3240
3256
  onObjectChanged() {
3241
- if (this.primaryTarget) {
3242
- //const TA1 = this.primaryTarget.getMatrixInWorld();
3243
- this.helperObject.updateMatrixWorld(true);
3244
- const TA2 = this.helperObject.matrixWorld.clone();
3245
- this.primaryTarget.onTransforming(TA2);
3246
- // const TA1Inverse = TA1.clone().invert();
3247
- //const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
3248
- this.targets.forEach((tar) => {
3249
- if (tar !== this.primaryTarget) {
3250
- let t = this.targetMatrixMap.get(tar);
3251
- if (t) {
3252
- let TB2 = new webgpu.Matrix4().multiplyMatrices(TA2, t); // B
3253
- 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
+ }
3254
3272
  }
3255
- }
3256
- });
3257
- }
3258
- if (this.onUpdateFunction) {
3259
- this.onUpdateFunction();
3260
- }
3273
+ });
3274
+ }
3275
+ if (this.onUpdateFunction) {
3276
+ this.onUpdateFunction();
3277
+ }
3278
+ }, 100);
3279
+ de();
3261
3280
  }
3262
3281
  set enable(newEnable) {
3263
3282
  this.control.enabled = newEnable;
@@ -1870,6 +1870,9 @@ class Viewport {
1870
1870
  else { //console.log("render renderer");
1871
1871
  this.renderer.render(this.app.world.scene, this.app.camera);
1872
1872
  }
1873
+ if (this.labelRenderer) {
1874
+ this.labelRenderer.render(this.app.world.scene, this.app.camera);
1875
+ }
1873
1876
  this.isRenderStateDirty = false;
1874
1877
  }
1875
1878
  async renderAsImage(width = 1024, height = 1024) {
@@ -3159,6 +3162,19 @@ class FirstPerson extends Pawn {
3159
3162
  }
3160
3163
  }
3161
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
+
3162
3178
  class TransformGizmo extends Pawn {
3163
3179
  get control() {
3164
3180
  if (!this._control) {
@@ -3236,26 +3252,29 @@ class TransformGizmo extends Pawn {
3236
3252
  }
3237
3253
  }
3238
3254
  onObjectChanged() {
3239
- if (this.primaryTarget) {
3240
- //const TA1 = this.primaryTarget.getMatrixInWorld();
3241
- this.helperObject.updateMatrixWorld(true);
3242
- const TA2 = this.helperObject.matrixWorld.clone();
3243
- this.primaryTarget.onTransforming(TA2);
3244
- // const TA1Inverse = TA1.clone().invert();
3245
- //const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
3246
- this.targets.forEach((tar) => {
3247
- if (tar !== this.primaryTarget) {
3248
- let t = this.targetMatrixMap.get(tar);
3249
- if (t) {
3250
- let TB2 = new Matrix4().multiplyMatrices(TA2, t); // B
3251
- 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
+ }
3252
3270
  }
3253
- }
3254
- });
3255
- }
3256
- if (this.onUpdateFunction) {
3257
- this.onUpdateFunction();
3258
- }
3271
+ });
3272
+ }
3273
+ if (this.onUpdateFunction) {
3274
+ this.onUpdateFunction();
3275
+ }
3276
+ }, 100);
3277
+ de();
3259
3278
  }
3260
3279
  set enable(newEnable) {
3261
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.7",
3
+ "version": "1.2.9",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",