lythreeframe 1.2.39 → 1.2.41

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.
@@ -175,6 +175,30 @@ class SceneComponent extends Component {
175
175
  elem.setLayers(layer);
176
176
  });
177
177
  }
178
+ getComponentById(id, bRecursive = true) {
179
+ if (this.uuid === id) {
180
+ return this;
181
+ }
182
+ if (bRecursive) {
183
+ let childComps = this.childrenComponents;
184
+ for (let i = 0; i < childComps.length; ++i) {
185
+ let comp = childComps[i].getComponentById(id, bRecursive);
186
+ if (comp) {
187
+ return comp;
188
+ }
189
+ }
190
+ }
191
+ else {
192
+ let childComps = this.childrenComponents;
193
+ for (let i = 0; i < childComps.length; ++i) {
194
+ let comp = childComps[i];
195
+ if (comp.uuid === id) {
196
+ return comp;
197
+ }
198
+ }
199
+ }
200
+ return null;
201
+ }
178
202
  getBoundsCenterPositionWS() {
179
203
  let ret = new webgpu.Vector3();
180
204
  this.getBounds().getCenter(ret);
@@ -2351,7 +2375,7 @@ const DefaultAppParam = {
2351
2375
  controllerClass: Controller,
2352
2376
  worldClass: World,
2353
2377
  viewportClass: Viewport,
2354
- }
2378
+ },
2355
2379
  };
2356
2380
 
2357
2381
  class Actor extends BaseObject {
@@ -2460,6 +2484,9 @@ class Actor extends BaseObject {
2460
2484
  }
2461
2485
  return null;
2462
2486
  }
2487
+ getComponentById(id) {
2488
+ return this.rootComponent.getComponentById(id);
2489
+ }
2463
2490
  getBoundsTopCenterPosition(bInWorldSpace = true) {
2464
2491
  let ret = new webgpu.Vector3();
2465
2492
  let bounds = this.rootComponent.getBounds();
@@ -2872,6 +2899,7 @@ class ThreeJsApp {
2872
2899
  worldClass: World,
2873
2900
  viewportClass: Viewport,
2874
2901
  };
2902
+ this._appParam.isRenderEveryFrame = appParam.isRenderEveryFrame;
2875
2903
  this._clock = new webgpu.Clock();
2876
2904
  this._camera = CameraFactory.createCamera(this._appParam.cameraParam);
2877
2905
  this._world = new this._appParam.classes.worldClass(this, this._appParam.worldParam ? this._appParam.worldParam : DefaultWorldParam);
@@ -2897,6 +2925,9 @@ class ThreeJsApp {
2897
2925
  this._tickingFunctions.forEach(func => {
2898
2926
  func(delta);
2899
2927
  });
2928
+ if (this._appParam.isRenderEveryFrame) {
2929
+ this.viewport.markRenderStateDirty();
2930
+ }
2900
2931
  this.viewport.render();
2901
2932
  }
2902
2933
  addTickingFunction(func) {
@@ -173,6 +173,30 @@ class SceneComponent extends Component {
173
173
  elem.setLayers(layer);
174
174
  });
175
175
  }
176
+ getComponentById(id, bRecursive = true) {
177
+ if (this.uuid === id) {
178
+ return this;
179
+ }
180
+ if (bRecursive) {
181
+ let childComps = this.childrenComponents;
182
+ for (let i = 0; i < childComps.length; ++i) {
183
+ let comp = childComps[i].getComponentById(id, bRecursive);
184
+ if (comp) {
185
+ return comp;
186
+ }
187
+ }
188
+ }
189
+ else {
190
+ let childComps = this.childrenComponents;
191
+ for (let i = 0; i < childComps.length; ++i) {
192
+ let comp = childComps[i];
193
+ if (comp.uuid === id) {
194
+ return comp;
195
+ }
196
+ }
197
+ }
198
+ return null;
199
+ }
176
200
  getBoundsCenterPositionWS() {
177
201
  let ret = new Vector3();
178
202
  this.getBounds().getCenter(ret);
@@ -2349,7 +2373,7 @@ const DefaultAppParam = {
2349
2373
  controllerClass: Controller,
2350
2374
  worldClass: World,
2351
2375
  viewportClass: Viewport,
2352
- }
2376
+ },
2353
2377
  };
2354
2378
 
2355
2379
  class Actor extends BaseObject {
@@ -2458,6 +2482,9 @@ class Actor extends BaseObject {
2458
2482
  }
2459
2483
  return null;
2460
2484
  }
2485
+ getComponentById(id) {
2486
+ return this.rootComponent.getComponentById(id);
2487
+ }
2461
2488
  getBoundsTopCenterPosition(bInWorldSpace = true) {
2462
2489
  let ret = new Vector3();
2463
2490
  let bounds = this.rootComponent.getBounds();
@@ -2870,6 +2897,7 @@ class ThreeJsApp {
2870
2897
  worldClass: World,
2871
2898
  viewportClass: Viewport,
2872
2899
  };
2900
+ this._appParam.isRenderEveryFrame = appParam.isRenderEveryFrame;
2873
2901
  this._clock = new Clock();
2874
2902
  this._camera = CameraFactory.createCamera(this._appParam.cameraParam);
2875
2903
  this._world = new this._appParam.classes.worldClass(this, this._appParam.worldParam ? this._appParam.worldParam : DefaultWorldParam);
@@ -2895,6 +2923,9 @@ class ThreeJsApp {
2895
2923
  this._tickingFunctions.forEach(func => {
2896
2924
  func(delta);
2897
2925
  });
2926
+ if (this._appParam.isRenderEveryFrame) {
2927
+ this.viewport.markRenderStateDirty();
2928
+ }
2898
2929
  this.viewport.render();
2899
2930
  }
2900
2931
  addTickingFunction(func) {
@@ -20,5 +20,6 @@ export interface AppParam {
20
20
  worldParam?: WorldParam;
21
21
  viewportParam: ViewportParam;
22
22
  classes?: AppClass;
23
+ isRenderEveryFrame?: boolean;
23
24
  }
24
25
  export declare const DefaultAppParam: AppParam;
@@ -28,6 +28,7 @@ export declare class Actor extends BaseObject {
28
28
  protected constructRootComponent(): SceneComponent;
29
29
  getBoundsCenterPosition(bInWorldSpace?: boolean): Vector3;
30
30
  getChildActorById(id: string, bRecursive?: boolean): Actor | null;
31
+ getComponentById(id: string): SceneComponent | null;
31
32
  getBoundsTopCenterPosition(bInWorldSpace?: boolean): Vector3;
32
33
  getBoundsBottomCenterPosition(bInWorldSpace?: boolean): Vector3;
33
34
  getBounds(): import("three").Box3;
@@ -17,6 +17,7 @@ export declare class SceneComponent extends Component {
17
17
  get isVisible(): boolean;
18
18
  setVisible(bVisible: boolean): void;
19
19
  setLayers(layer: number): void;
20
+ getComponentById(id: string, bRecursive?: boolean): SceneComponent | null;
20
21
  getBoundsCenterPositionWS(): Vector3;
21
22
  getBoundsTopCenterPositionWS(): Vector3;
22
23
  getBoundsBottomCenterPositionWS(): Vector3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.2.39",
3
+ "version": "1.2.41",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",