lythreeframe 1.2.35 → 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();
@@ -3007,6 +3020,74 @@ class DirectionalLightActor extends Actor {
3007
3020
  }
3008
3021
  }
3009
3022
 
3023
+ class AmbientLightComponent extends LightComponent {
3024
+ get threeObject() {
3025
+ if (!this.obj) {
3026
+ throw Error("three object is invalid");
3027
+ }
3028
+ return this.obj;
3029
+ }
3030
+ set threeObject(newThreeObject) {
3031
+ this.obj = newThreeObject;
3032
+ if (this.obj) {
3033
+ this.obj.userData["LYObject"] = this;
3034
+ }
3035
+ }
3036
+ get castShadow() {
3037
+ return this.threeObject.castShadow;
3038
+ }
3039
+ set castShadow(value) {
3040
+ this.threeObject.castShadow = value;
3041
+ }
3042
+ constructor(app, color = 0xffffff, intensity = 10, uuid) {
3043
+ super(app, uuid);
3044
+ this.threeObject.color.set(color);
3045
+ this.threeObject.intensity = intensity;
3046
+ }
3047
+ createDefaultObject() {
3048
+ return new webgpu.AmbientLight(0xffffff, 10);
3049
+ }
3050
+ setPosition(...args) {
3051
+ if (args.length === 1) {
3052
+ super.setPosition(args[0]);
3053
+ }
3054
+ else {
3055
+ super.setPosition(args[0], args[1], args[2]);
3056
+ }
3057
+ this.update();
3058
+ }
3059
+ update() {
3060
+ if (this.world)
3061
+ this.world.viewport.markRenderStateDirty();
3062
+ }
3063
+ onAddedToWorld(world) {
3064
+ if (!this.threeObject) {
3065
+ throw Error("three object is invalid");
3066
+ }
3067
+ super.onAddedToWorld(world);
3068
+ }
3069
+ destroy() {
3070
+ super.destroy();
3071
+ }
3072
+ }
3073
+
3074
+ class AmbientLightActor extends Actor {
3075
+ constructor(app, color = 0xffffff, intensity = 1, uuid) {
3076
+ super(app, uuid);
3077
+ this.lightComponent = null;
3078
+ this.lightComponent = this.rootComponent;
3079
+ if (this.lightComponent) {
3080
+ this.lightComponent.color = color;
3081
+ this.lightComponent.intensity = intensity;
3082
+ this.lightComponent.castShadow = true;
3083
+ }
3084
+ this.lightComponent.castShadow = true;
3085
+ }
3086
+ constructRootComponent() {
3087
+ return new AmbientLightComponent(this.app);
3088
+ }
3089
+ }
3090
+
3010
3091
  class BoxComponent extends MeshComponent {
3011
3092
  constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial(), uuid) {
3012
3093
  super(app, new webgpu.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
@@ -3430,6 +3511,8 @@ class TransformGizmo extends Pawn {
3430
3511
  }
3431
3512
 
3432
3513
  exports.Actor = Actor;
3514
+ exports.AmbientLightActor = AmbientLightActor;
3515
+ exports.AmbientLightComponent = AmbientLightComponent;
3433
3516
  exports.AssetManager = AssetManager;
3434
3517
  exports.BoxActor = BoxActor;
3435
3518
  exports.BoxComponent = BoxComponent;
@@ -1,4 +1,4 @@
1
- import { MathUtils, Object3D, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material, NearestFilter, WebGPURenderer, PostProcessing, Color, Vector2, Raycaster, OrthographicCamera, PerspectiveCamera, Clock, DirectionalLight, MeshStandardMaterial, BoxGeometry, MeshBasicMaterial, PlaneGeometry, SphereGeometry } from 'three/webgpu';
1
+ import { MathUtils, Object3D, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material, NearestFilter, WebGPURenderer, PostProcessing, Color, Vector2, Raycaster, OrthographicCamera, PerspectiveCamera, Clock, DirectionalLight, AmbientLight, MeshStandardMaterial, BoxGeometry, MeshBasicMaterial, PlaneGeometry, SphereGeometry } from 'three/webgpu';
2
2
  import { GLTFLoader, DRACOLoader, CSS2DRenderer, OrbitControls } from 'three/examples/jsm/Addons.js';
3
3
  import { pass, mrt, output, uniform, metalness, transformedNormalView, time, oscSine } from 'three/tsl';
4
4
  import { dof } from 'three/addons/tsl/display/DepthOfFieldNode.js';
@@ -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();
@@ -3005,6 +3018,74 @@ class DirectionalLightActor extends Actor {
3005
3018
  }
3006
3019
  }
3007
3020
 
3021
+ class AmbientLightComponent extends LightComponent {
3022
+ get threeObject() {
3023
+ if (!this.obj) {
3024
+ throw Error("three object is invalid");
3025
+ }
3026
+ return this.obj;
3027
+ }
3028
+ set threeObject(newThreeObject) {
3029
+ this.obj = newThreeObject;
3030
+ if (this.obj) {
3031
+ this.obj.userData["LYObject"] = this;
3032
+ }
3033
+ }
3034
+ get castShadow() {
3035
+ return this.threeObject.castShadow;
3036
+ }
3037
+ set castShadow(value) {
3038
+ this.threeObject.castShadow = value;
3039
+ }
3040
+ constructor(app, color = 0xffffff, intensity = 10, uuid) {
3041
+ super(app, uuid);
3042
+ this.threeObject.color.set(color);
3043
+ this.threeObject.intensity = intensity;
3044
+ }
3045
+ createDefaultObject() {
3046
+ return new AmbientLight(0xffffff, 10);
3047
+ }
3048
+ setPosition(...args) {
3049
+ if (args.length === 1) {
3050
+ super.setPosition(args[0]);
3051
+ }
3052
+ else {
3053
+ super.setPosition(args[0], args[1], args[2]);
3054
+ }
3055
+ this.update();
3056
+ }
3057
+ update() {
3058
+ if (this.world)
3059
+ this.world.viewport.markRenderStateDirty();
3060
+ }
3061
+ onAddedToWorld(world) {
3062
+ if (!this.threeObject) {
3063
+ throw Error("three object is invalid");
3064
+ }
3065
+ super.onAddedToWorld(world);
3066
+ }
3067
+ destroy() {
3068
+ super.destroy();
3069
+ }
3070
+ }
3071
+
3072
+ class AmbientLightActor extends Actor {
3073
+ constructor(app, color = 0xffffff, intensity = 1, uuid) {
3074
+ super(app, uuid);
3075
+ this.lightComponent = null;
3076
+ this.lightComponent = this.rootComponent;
3077
+ if (this.lightComponent) {
3078
+ this.lightComponent.color = color;
3079
+ this.lightComponent.intensity = intensity;
3080
+ this.lightComponent.castShadow = true;
3081
+ }
3082
+ this.lightComponent.castShadow = true;
3083
+ }
3084
+ constructRootComponent() {
3085
+ return new AmbientLightComponent(this.app);
3086
+ }
3087
+ }
3088
+
3008
3089
  class BoxComponent extends MeshComponent {
3009
3090
  constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshStandardMaterial(), uuid) {
3010
3091
  super(app, new BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
@@ -3427,4 +3508,4 @@ class TransformGizmo extends Pawn {
3427
3508
  }
3428
3509
  }
3429
3510
 
3430
- export { Actor, AssetManager, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAAParams, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOrthographicCameraParam, DefaultOutlineParams, DefaultPerspectiveCameraParam, DefaultPostProcessParam, DefaultRendererParameters, DefaultSSRParam, DefaultSkyParam, DefaultViewportParam, DefaultWorldParam, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, GeometryAssetPointer, LabelComponent, LevelActor, LevelComponent, MaterialAssetPointer, MeshComponent, Orbital, PlaneActor, PlaneComponent, PostProcessStepType, SceneComponent, SkyActor, SkyComponent, SphereComponent, TAssetPointer, TSmartPointer, TextureAssetPointer, ThreeJsApp, ThreeObjectLibrary, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
3511
+ export { Actor, AmbientLightActor, AmbientLightComponent, AssetManager, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAAParams, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOrthographicCameraParam, DefaultOutlineParams, DefaultPerspectiveCameraParam, DefaultPostProcessParam, DefaultRendererParameters, DefaultSSRParam, DefaultSkyParam, DefaultViewportParam, DefaultWorldParam, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, GeometryAssetPointer, LabelComponent, LevelActor, LevelComponent, MaterialAssetPointer, MeshComponent, Orbital, PlaneActor, PlaneComponent, PostProcessStepType, SceneComponent, SkyActor, SkyComponent, SphereComponent, TAssetPointer, TSmartPointer, TextureAssetPointer, ThreeJsApp, ThreeObjectLibrary, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export type { RendererParameters } from './lythreeframe/Frame/Parameters/Rendere
22
22
  export { DefaultRendererParameters } from './lythreeframe/Frame/Parameters/RendererParameters';
23
23
  export { Actor } from "./lythreeframe/Object/Actor";
24
24
  export { DirectionalLightActor } from "./lythreeframe/Object/Actors/Light/DirectionalLightActor";
25
+ export { AmbientLightActor } from './lythreeframe/Object/Actors/Light/AmbientLightActor';
25
26
  export { BoxActor } from "./lythreeframe/Object/Actors/Shape/BoxActor";
26
27
  export { SkyActor } from "./lythreeframe/Object/Actors/Sky/SkyActor";
27
28
  export { PlaneActor } from "./lythreeframe/Object/Actors/Shape/PlaneActor";
@@ -33,6 +34,7 @@ export { PlaneComponent } from "./lythreeframe/Object/Components/Mesh/Shape/Plan
33
34
  export { SphereComponent } from "./lythreeframe/Object/Components/Mesh/Shape/SphereComponent";
34
35
  export { LevelComponent } from "./lythreeframe/Object/Components/Level/LevelComponent";
35
36
  export { DirectionalLightComponent } from "./lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent";
37
+ export { AmbientLightComponent } from './lythreeframe/Object/Components/Light/AmbientLight/AmbientLightComponent';
36
38
  export { LabelComponent } from "./lythreeframe/Object/Components/2D/2DComponent";
37
39
  export { SkyComponent } from "./lythreeframe/Object/Components/Sky/SkyComponent";
38
40
  export type { SkyComponentParam } from "./lythreeframe/Object/Components/Sky/SkyComponent";
@@ -0,0 +1,9 @@
1
+ import { ColorRepresentation } from "three/webgpu";
2
+ import { Actor } from "../../Actor";
3
+ import { ThreeJsApp } from "../../../ThreeJsApp";
4
+ import { AmbientLightComponent } from "../../Components/Light/AmbientLight/AmbientLightComponent";
5
+ export declare class AmbientLightActor extends Actor {
6
+ protected lightComponent: AmbientLightComponent | null;
7
+ constructor(app: ThreeJsApp, color?: ColorRepresentation, intensity?: number, uuid?: string);
8
+ protected constructRootComponent(): AmbientLightComponent;
9
+ }
@@ -0,0 +1,16 @@
1
+ import { LightComponent } from "../LightComponent";
2
+ import { ColorRepresentation, AmbientLight, Vector3 } from "three/webgpu";
3
+ import { World } from "../../../../Frame/World";
4
+ import { ThreeJsApp } from "../../../../ThreeJsApp";
5
+ export declare class AmbientLightComponent extends LightComponent {
6
+ get threeObject(): AmbientLight;
7
+ set threeObject(newThreeObject: AmbientLight);
8
+ get castShadow(): boolean;
9
+ set castShadow(value: boolean);
10
+ constructor(app: ThreeJsApp, color?: ColorRepresentation, intensity?: number, uuid?: string);
11
+ protected createDefaultObject(): AmbientLight;
12
+ setPosition(...args: [Vector3] | [number, number, number]): void;
13
+ update(): void;
14
+ onAddedToWorld(world: World): void;
15
+ destroy(): void;
16
+ }
@@ -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.35",
3
+ "version": "1.2.37",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",