lythreeframe 1.2.36 → 1.2.37

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.
@@ -2839,6 +2839,7 @@ class ThreeJsApp {
2839
2839
  return this._onCameraChangedDelegate;
2840
2840
  }
2841
2841
  constructor(appParam = DefaultAppParam) {
2842
+ this._tickingFunctions = [];
2842
2843
  this._appParam = { viewportParam: DefaultViewportParam };
2843
2844
  this._onCameraChangedDelegate = new Delegate();
2844
2845
  this._appParam.cameraParam = appParam.cameraParam ? appParam.cameraParam : DefaultCameraParam;
@@ -2873,8 +2874,20 @@ class ThreeJsApp {
2873
2874
  const delta = this._clock.getDelta();
2874
2875
  this._controller.tick(delta);
2875
2876
  this.world.tick(delta);
2877
+ this._tickingFunctions.forEach(func => {
2878
+ func(delta);
2879
+ });
2876
2880
  this.viewport.render();
2877
2881
  }
2882
+ addTickingFunction(func) {
2883
+ this._tickingFunctions.push(func);
2884
+ }
2885
+ removeTickingFunction(func) {
2886
+ const index = this._tickingFunctions.indexOf(func);
2887
+ if (index >= 0) {
2888
+ this._tickingFunctions.splice(index, 1);
2889
+ }
2890
+ }
2878
2891
  destroy() {
2879
2892
  this.onCameraChangedDelegate.clear();
2880
2893
  this.controller.destroy();
@@ -2837,6 +2837,7 @@ class ThreeJsApp {
2837
2837
  return this._onCameraChangedDelegate;
2838
2838
  }
2839
2839
  constructor(appParam = DefaultAppParam) {
2840
+ this._tickingFunctions = [];
2840
2841
  this._appParam = { viewportParam: DefaultViewportParam };
2841
2842
  this._onCameraChangedDelegate = new Delegate();
2842
2843
  this._appParam.cameraParam = appParam.cameraParam ? appParam.cameraParam : DefaultCameraParam;
@@ -2871,8 +2872,20 @@ class ThreeJsApp {
2871
2872
  const delta = this._clock.getDelta();
2872
2873
  this._controller.tick(delta);
2873
2874
  this.world.tick(delta);
2875
+ this._tickingFunctions.forEach(func => {
2876
+ func(delta);
2877
+ });
2874
2878
  this.viewport.render();
2875
2879
  }
2880
+ addTickingFunction(func) {
2881
+ this._tickingFunctions.push(func);
2882
+ }
2883
+ removeTickingFunction(func) {
2884
+ const index = this._tickingFunctions.indexOf(func);
2885
+ if (index >= 0) {
2886
+ this._tickingFunctions.splice(index, 1);
2887
+ }
2888
+ }
2876
2889
  destroy() {
2877
2890
  this.onCameraChangedDelegate.clear();
2878
2891
  this.controller.destroy();
@@ -1,5 +1,5 @@
1
1
  import { LightComponent } from "../LightComponent";
2
- import { AmbientLight, ColorRepresentation, Vector3 } from "three/webgpu";
2
+ import { ColorRepresentation, AmbientLight, Vector3 } from "three/webgpu";
3
3
  import { World } from "../../../../Frame/World";
4
4
  import { ThreeJsApp } from "../../../../ThreeJsApp";
5
5
  export declare class AmbientLightComponent extends LightComponent {
@@ -19,6 +19,7 @@ export declare class ThreeJsApp {
19
19
  protected _viewport: Viewport;
20
20
  protected _controller: Controller;
21
21
  protected _assetManager: AssetManager;
22
+ protected _tickingFunctions: Array<(delta: number) => void>;
22
23
  get appParam(): AppParam;
23
24
  protected _appParam: AppParam;
24
25
  get onCameraChangedDelegate(): Delegate<[void]>;
@@ -27,6 +28,8 @@ export declare class ThreeJsApp {
27
28
  protected postConstruct(): void;
28
29
  init(): void;
29
30
  tick(): void;
31
+ addTickingFunction(func: (deltaTime: number) => void): void;
32
+ removeTickingFunction(func: (deltaTime: number) => void): void;
30
33
  destroy(): void;
31
34
  updateCamera(param: CameraParam): void;
32
35
  onWindowResize(width: number, height: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.2.36",
3
+ "version": "1.2.37",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",