lythreeframe 1.2.38 → 1.2.40

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 {
@@ -2443,6 +2467,26 @@ class Actor extends BaseObject {
2443
2467
  return ret;
2444
2468
  }
2445
2469
  }
2470
+ getChildActorById(id, bRecursive = true) {
2471
+ const directChildren = this.childActors;
2472
+ for (const child of directChildren) {
2473
+ if (child.uuid === id) {
2474
+ return child;
2475
+ }
2476
+ }
2477
+ if (bRecursive) {
2478
+ for (const child of directChildren) {
2479
+ const foundInChild = child.getChildActorById(id, true);
2480
+ if (foundInChild) {
2481
+ return foundInChild;
2482
+ }
2483
+ }
2484
+ }
2485
+ return null;
2486
+ }
2487
+ getComponentById(id) {
2488
+ return this.rootComponent.getComponentById(id);
2489
+ }
2446
2490
  getBoundsTopCenterPosition(bInWorldSpace = true) {
2447
2491
  let ret = new webgpu.Vector3();
2448
2492
  let bounds = this.rootComponent.getBounds();
@@ -2880,6 +2924,9 @@ class ThreeJsApp {
2880
2924
  this._tickingFunctions.forEach(func => {
2881
2925
  func(delta);
2882
2926
  });
2927
+ if (this._appParam.isRenderEveryFrame) {
2928
+ this.viewport.markRenderStateDirty();
2929
+ }
2883
2930
  this.viewport.render();
2884
2931
  }
2885
2932
  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 {
@@ -2441,6 +2465,26 @@ class Actor extends BaseObject {
2441
2465
  return ret;
2442
2466
  }
2443
2467
  }
2468
+ getChildActorById(id, bRecursive = true) {
2469
+ const directChildren = this.childActors;
2470
+ for (const child of directChildren) {
2471
+ if (child.uuid === id) {
2472
+ return child;
2473
+ }
2474
+ }
2475
+ if (bRecursive) {
2476
+ for (const child of directChildren) {
2477
+ const foundInChild = child.getChildActorById(id, true);
2478
+ if (foundInChild) {
2479
+ return foundInChild;
2480
+ }
2481
+ }
2482
+ }
2483
+ return null;
2484
+ }
2485
+ getComponentById(id) {
2486
+ return this.rootComponent.getComponentById(id);
2487
+ }
2444
2488
  getBoundsTopCenterPosition(bInWorldSpace = true) {
2445
2489
  let ret = new Vector3();
2446
2490
  let bounds = this.rootComponent.getBounds();
@@ -2878,6 +2922,9 @@ class ThreeJsApp {
2878
2922
  this._tickingFunctions.forEach(func => {
2879
2923
  func(delta);
2880
2924
  });
2925
+ if (this._appParam.isRenderEveryFrame) {
2926
+ this.viewport.markRenderStateDirty();
2927
+ }
2881
2928
  this.viewport.render();
2882
2929
  }
2883
2930
  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;
@@ -27,6 +27,8 @@ export declare class Actor extends BaseObject {
27
27
  constructor(app: ThreeJsApp, uuid?: string);
28
28
  protected constructRootComponent(): SceneComponent;
29
29
  getBoundsCenterPosition(bInWorldSpace?: boolean): Vector3;
30
+ getChildActorById(id: string, bRecursive?: boolean): Actor | null;
31
+ getComponentById(id: string): SceneComponent | null;
30
32
  getBoundsTopCenterPosition(bInWorldSpace?: boolean): Vector3;
31
33
  getBoundsBottomCenterPosition(bInWorldSpace?: boolean): Vector3;
32
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.38",
3
+ "version": "1.2.40",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",