lythreeframe 1.1.19 → 1.2.0

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.
Files changed (27) hide show
  1. package/dist/bundle.cjs.js +102 -80
  2. package/dist/bundle.esm.js +104 -83
  3. package/dist/index.d.ts +1 -0
  4. package/dist/lythreeframe/AssetManagement/AssetManager.d.ts +1 -1
  5. package/dist/lythreeframe/Factory/CameraFactory.d.ts +1 -1
  6. package/dist/lythreeframe/Library/Math.d.ts +5 -5
  7. package/dist/lythreeframe/Object/Actor.d.ts +7 -7
  8. package/dist/lythreeframe/Object/Actors/Level/LevelActor.d.ts +3 -1
  9. package/dist/lythreeframe/Object/Actors/Light/DirectionalLightActor.d.ts +2 -2
  10. package/dist/lythreeframe/Object/Actors/Shape/BoxActor.d.ts +2 -2
  11. package/dist/lythreeframe/Object/Actors/Shape/PlaneActor.d.ts +2 -4
  12. package/dist/lythreeframe/Object/Actors/Sky/SkyActor.d.ts +1 -1
  13. package/dist/lythreeframe/Object/Components/2D/2DComponent.d.ts +2 -1
  14. package/dist/lythreeframe/Object/Components/Component.d.ts +2 -1
  15. package/dist/lythreeframe/Object/Components/Level/LevelComponent.d.ts +9 -0
  16. package/dist/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.d.ts +2 -1
  17. package/dist/lythreeframe/Object/Components/Light/LightComponent.d.ts +1 -1
  18. package/dist/lythreeframe/Object/Components/Mesh/MeshComponent.d.ts +3 -2
  19. package/dist/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.d.ts +1 -1
  20. package/dist/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.d.ts +1 -1
  21. package/dist/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.d.ts +2 -1
  22. package/dist/lythreeframe/Object/Components/SceneComponent.d.ts +14 -14
  23. package/dist/lythreeframe/Object/Components/Sky/SkyComponent.d.ts +2 -1
  24. package/dist/lythreeframe/Object/PawnV2/Oribital.d.ts +1 -1
  25. package/dist/lythreeframe/Object/PawnV2/Pawn.d.ts +1 -1
  26. package/dist/lythreeframe/PostProcess/Param/ToneMapping.d.ts +1 -1
  27. package/package.json +39 -39
@@ -85,14 +85,17 @@ class Component extends BaseObject {
85
85
  set name(name) {
86
86
  this._name = name;
87
87
  }
88
- constructor(newThreeObject) {
89
- super(newThreeObject.uuid);
88
+ constructor(uuid) {
89
+ super(uuid ? uuid : webgpu.MathUtils.generateUUID());
90
90
  this.obj = null;
91
91
  this._parentActor = null;
92
92
  this._name = "Component";
93
93
  this._parentActor = null;
94
- this.threeObject = newThreeObject;
95
- this._name = `${newThreeObject.type}Component`;
94
+ this.threeObject = this.createDefaultObject();
95
+ this._name = `${this.threeObject.type}Component`;
96
+ }
97
+ createDefaultObject(_arg) {
98
+ return new webgpu.Object3D();
96
99
  }
97
100
  destroyObject() {
98
101
  if (!this.obj) {
@@ -128,15 +131,15 @@ class SceneComponent extends Component {
128
131
  get world() {
129
132
  return this.app.world;
130
133
  }
131
- constructor(app, newThreeObject) {
132
- super(newThreeObject);
134
+ constructor(app, uuid) {
135
+ super(uuid);
133
136
  this.bCanHover = false;
134
137
  this.bCanClick = false;
135
138
  this.app = app;
136
- this._name = "SceneComponent";
139
+ this.name = "SceneComponent";
137
140
  }
138
- createDefaultThreeObject() {
139
- this.threeObject = new webgpu.Group();
141
+ createDefaultObject() {
142
+ return new webgpu.Object3D();
140
143
  }
141
144
  tick(deltaTime) {
142
145
  super.tick(deltaTime);
@@ -689,6 +692,9 @@ class SceneComponent extends Component {
689
692
 
690
693
  class MeshComponent extends SceneComponent {
691
694
  get threeObject() {
695
+ if (!this.obj) {
696
+ throw new Error("threeObject is null");
697
+ }
692
698
  return this.obj;
693
699
  }
694
700
  set threeObject(newThreeObject) {
@@ -767,7 +773,7 @@ class MeshComponent extends SceneComponent {
767
773
  }
768
774
  this._materialPtr = matPtrs;
769
775
  }
770
- constructor(app, geometry, material) {
776
+ constructor(app, geometry, material, uuid) {
771
777
  let matPtrs = [];
772
778
  let mats = Array.isArray(material) ? material : [material];
773
779
  mats.forEach((elem) => {
@@ -775,15 +781,18 @@ class MeshComponent extends SceneComponent {
775
781
  if (ptr)
776
782
  matPtrs.push(ptr);
777
783
  });
778
- let newMesh = new webgpu.Mesh(geometry, material);
779
- super(app, newMesh);
784
+ super(app, uuid);
780
785
  this.obj = null;
781
786
  this._geometryPtr = app.assetManager.addGeometryAsset(geometry);
782
787
  this._materialPtr = matPtrs;
783
788
  matPtrs.forEach((elem) => {
784
789
  elem.addRef();
785
790
  });
786
- this.threeObject = newMesh;
791
+ this.threeObject.material = material;
792
+ this.threeObject.geometry = geometry;
793
+ }
794
+ createDefaultObject() {
795
+ return new webgpu.Mesh();
787
796
  }
788
797
  set castShadow(bCast) {
789
798
  if (this.threeObject)
@@ -2360,8 +2369,8 @@ class Actor extends BaseObject {
2360
2369
  this.app.world.removeTickableActor(this);
2361
2370
  }
2362
2371
  }
2363
- constructor(app, myThreeObject = null) {
2364
- super();
2372
+ constructor(app, uuid) {
2373
+ super(uuid);
2365
2374
  this._name = "Actor";
2366
2375
  this._rootComponent = null;
2367
2376
  this._world = null;
@@ -2370,19 +2379,11 @@ class Actor extends BaseObject {
2370
2379
  this.onHoverBeginEvent = [];
2371
2380
  this.onHoverEndEvent = [];
2372
2381
  this.app = app;
2373
- this.constructRootComponent(myThreeObject);
2382
+ this.rootComponent = this.constructRootComponent();
2383
+ this.rootComponent.parentActor = this;
2374
2384
  }
2375
- constructRootComponent(myThreeObject = null) {
2376
- let tObject = myThreeObject ? myThreeObject : new webgpu.Group();
2377
- if (tObject.isMesh) {
2378
- let mesh = tObject;
2379
- this._rootComponent = new MeshComponent(this.app, mesh.geometry, mesh.material);
2380
- this.rootComponent.parentActor = this;
2381
- }
2382
- else {
2383
- this._rootComponent = new SceneComponent(this.app, tObject);
2384
- this.rootComponent.parentActor = this;
2385
- }
2385
+ constructRootComponent() {
2386
+ return new SceneComponent(this.app);
2386
2387
  }
2387
2388
  getBoundsCenterPosition(bInWorldSpace = true) {
2388
2389
  let ret = new webgpu.Vector3();
@@ -2704,6 +2705,27 @@ class ThreeObjectLibrary {
2704
2705
  }
2705
2706
  }
2706
2707
 
2708
+ class LevelComponent extends SceneComponent {
2709
+ get threeObject() {
2710
+ if (!this.obj) {
2711
+ throw Error("three object is invalid");
2712
+ }
2713
+ return this.obj;
2714
+ }
2715
+ set threeObject(newThreeObject) {
2716
+ this.obj = newThreeObject;
2717
+ if (this.obj) {
2718
+ this.obj.userData["LYObject"] = this;
2719
+ }
2720
+ }
2721
+ constructor(app, uuid) {
2722
+ super(app, uuid);
2723
+ }
2724
+ createDefaultObject() {
2725
+ return new three.Scene();
2726
+ }
2727
+ }
2728
+
2707
2729
  class LevelActor extends Actor {
2708
2730
  get scene() {
2709
2731
  if (!this._scene) {
@@ -2711,13 +2733,15 @@ class LevelActor extends Actor {
2711
2733
  }
2712
2734
  return this._scene;
2713
2735
  }
2714
- constructor(app) {
2715
- let scene = new webgpu.Scene();
2716
- super(app, scene);
2736
+ constructor(app, uuid) {
2737
+ super(app, uuid);
2717
2738
  this._scene = null;
2718
- this._scene = scene;
2739
+ this._scene = this.rootComponent.threeObject;
2719
2740
  this.isTickEnabled = false;
2720
2741
  }
2742
+ constructRootComponent() {
2743
+ return new LevelComponent(this.app, this.uuid);
2744
+ }
2721
2745
  tick(_deltaTime) {
2722
2746
  if (!this.isTickEnabled) {
2723
2747
  return;
@@ -2726,13 +2750,14 @@ class LevelActor extends Actor {
2726
2750
  }
2727
2751
  destroy() {
2728
2752
  this.clearLevel();
2753
+ super.destroy();
2729
2754
  }
2730
2755
  clearLevel() {
2731
2756
  this.childActors.forEach((elem) => {
2732
2757
  elem.destroy();
2733
2758
  });
2734
2759
  this.scene.traverse((child) => {
2735
- if (child instanceof three.Mesh) {
2760
+ if (child instanceof webgpu.Mesh) {
2736
2761
  ThreeObjectLibrary.disposeMeshResource(child);
2737
2762
  }
2738
2763
  });
@@ -2862,9 +2887,9 @@ class LightComponent extends SceneComponent {
2862
2887
  set intensity(intensity) {
2863
2888
  this.threeObject.intensity = intensity;
2864
2889
  }
2865
- constructor(app, light) {
2866
- super(app, light);
2867
- this.obj = light;
2890
+ constructor(app, uuid) {
2891
+ super(app, uuid);
2892
+ this.obj = null;
2868
2893
  }
2869
2894
  }
2870
2895
 
@@ -2887,11 +2912,14 @@ class DirectionalLightComponent extends LightComponent {
2887
2912
  set castShadow(value) {
2888
2913
  this.threeObject.castShadow = value;
2889
2914
  }
2890
- constructor(app, color = 0xffffff, intensity = 10) {
2891
- let obj = new webgpu.DirectionalLight(color, intensity);
2892
- super(app, obj);
2893
- this.obj = obj;
2894
- obj.castShadow = true;
2915
+ constructor(app, color = 0xffffff, intensity = 10, uuid) {
2916
+ super(app, uuid);
2917
+ this.obj = null;
2918
+ this.threeObject.color.set(color);
2919
+ this.threeObject.intensity = intensity;
2920
+ }
2921
+ createDefaultObject() {
2922
+ return new webgpu.DirectionalLight(0xffffff, 10);
2895
2923
  }
2896
2924
  setPosition(...args) {
2897
2925
  if (args.length === 1) {
@@ -2918,34 +2946,34 @@ class DirectionalLightComponent extends LightComponent {
2918
2946
  }
2919
2947
 
2920
2948
  class DirectionalLightActor extends Actor {
2921
- constructor(app, color = 0xffffff, intensity = 1) {
2922
- super(app);
2949
+ constructor(app, color = 0xffffff, intensity = 1, uuid) {
2950
+ super(app, uuid);
2923
2951
  this.lightComponent = null;
2924
2952
  this.lightComponent = this.rootComponent;
2925
2953
  if (this.lightComponent) {
2926
2954
  this.lightComponent.color = color;
2927
2955
  this.lightComponent.intensity = intensity;
2956
+ this.lightComponent.castShadow = true;
2928
2957
  }
2929
2958
  this.lightComponent.castShadow = true;
2930
2959
  }
2931
2960
  constructRootComponent() {
2932
- this.lightComponent = new DirectionalLightComponent(this.app);
2933
- this.rootComponent = this.lightComponent;
2934
- this.lightComponent.castShadow = true;
2935
- this.rootComponent.parentActor = this;
2961
+ return new DirectionalLightComponent(this.app);
2936
2962
  }
2937
2963
  }
2938
2964
 
2939
2965
  class BoxComponent extends MeshComponent {
2940
- constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial()) {
2941
- super(app, new webgpu.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material);
2966
+ constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial(), uuid) {
2967
+ super(app, new webgpu.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
2942
2968
  }
2943
2969
  }
2944
2970
 
2945
2971
  class BoxActor extends Actor {
2946
- constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshBasicMaterial()) {
2947
- super(app);
2948
- this.addComponent(new BoxComponent(this.app, width, height, depth, widthSegments, heightSegments, depthSegments, material));
2972
+ constructor(app, uuid) {
2973
+ super(app, uuid);
2974
+ }
2975
+ constructRootComponent() {
2976
+ this.rootComponent = new BoxComponent(this.app);
2949
2977
  }
2950
2978
  }
2951
2979
 
@@ -2970,18 +2998,19 @@ class SkyComponent extends SceneComponent {
2970
2998
  this.obj.userData["LYObject"] = this;
2971
2999
  }
2972
3000
  }
2973
- constructor(app, skyparam) {
2974
- let obj = new SkyMesh_js.SkyMesh();
2975
- super(app, obj);
3001
+ constructor(app, skyparam, uuid) {
3002
+ super(app, uuid);
3003
+ this.obj = null;
2976
3004
  this.skyParam = DefaultSkyParam;
2977
3005
  this.sunPosition = new webgpu.Vector3();
2978
- this.obj = obj;
2979
- this.name = "SkyComponent";
2980
3006
  if (skyparam) {
2981
3007
  this.skyParam = skyparam;
2982
3008
  }
2983
3009
  this.updateSky();
2984
3010
  }
3011
+ createDefaultObject() {
3012
+ return new SkyMesh_js.SkyMesh();
3013
+ }
2985
3014
  updateSky() {
2986
3015
  var _a, _b;
2987
3016
  this.threeObject.turbidity.value = this.skyParam.turbidity;
@@ -2995,7 +3024,9 @@ class SkyComponent extends SceneComponent {
2995
3024
  (_b = (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport) === null || _b === void 0 ? void 0 : _b.markRenderStateDirty();
2996
3025
  }
2997
3026
  destroyObject() {
2998
- ThreeObjectLibrary.disposeMeshResource(this.obj);
3027
+ if (this.obj) {
3028
+ ThreeObjectLibrary.disposeMeshResource(this.obj);
3029
+ }
2999
3030
  }
3000
3031
  }
3001
3032
 
@@ -3010,40 +3041,31 @@ class SkyActor extends Actor {
3010
3041
  this.setScale(45000, 45000, 45000);
3011
3042
  }
3012
3043
  constructRootComponent() {
3013
- this.skyComponent = new SkyComponent(this.app);
3014
- this.rootComponent = this.skyComponent;
3015
- this.rootComponent.parentActor = this;
3044
+ return new SkyComponent(this.app);
3016
3045
  }
3017
3046
  }
3018
3047
 
3019
3048
  class PlaneComponent extends MeshComponent {
3020
- constructor(app, width, height, material, widthSegments = 1, heightSegments = 1) {
3021
- super(app, new webgpu.PlaneGeometry(width, height, widthSegments, heightSegments), material);
3049
+ constructor(app, width, height, material, widthSegments = 1, heightSegments = 1, uuid) {
3050
+ super(app, new webgpu.PlaneGeometry(width, height, widthSegments, heightSegments), material, uuid);
3022
3051
  }
3023
3052
  }
3024
3053
 
3025
3054
  class PlaneActor extends Actor {
3026
- get planeComponent() {
3027
- return this._planeComponent;
3055
+ constructor(app, uuid) {
3056
+ super(app, uuid);
3028
3057
  }
3029
- constructor(app, width, height, material = new webgpu.MeshBasicMaterial(), widthSegments = 1, heightSegments = 1) {
3030
- super(app);
3031
- this._planeComponent = new PlaneComponent(this.app, width, height, material, widthSegments, heightSegments);
3032
- this._planeComponent.setRotation(Math.PI * 0.5 * -1, 0, 0);
3033
- this.addComponent(this._planeComponent);
3034
- this._planeComponent.receiveShadow = true;
3058
+ constructRootComponent() {
3059
+ return new PlaneComponent(this.app, 1, 1, new webgpu.MeshBasicMaterial(), 1, 1, this.uuid);
3035
3060
  }
3036
3061
  destroy() {
3037
- var _a;
3038
- (_a = this._planeComponent) === null || _a === void 0 ? void 0 : _a.destroy();
3039
- this._planeComponent = null;
3040
3062
  super.destroy();
3041
3063
  }
3042
3064
  }
3043
3065
 
3044
3066
  class SphereComponent extends MeshComponent {
3045
- constructor(app, radius, material = new webgpu.MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
3046
- super(app, new webgpu.SphereGeometry(radius, widthSegments, heightSegments), material);
3067
+ constructor(app, radius, material = new webgpu.MeshBasicMaterial(), widthSegments = 32, heightSegments = 16, uuid) {
3068
+ super(app, new webgpu.SphereGeometry(radius, widthSegments, heightSegments), material, uuid);
3047
3069
  }
3048
3070
  }
3049
3071
 
@@ -3057,11 +3079,10 @@ class LabelComponent extends SceneComponent {
3057
3079
  this.obj.userData["LYObject"] = this;
3058
3080
  }
3059
3081
  }
3060
- constructor(app, domElement, center = new webgpu.Vector2(0.5, 1)) {
3061
- let obj = new CSS2DRenderer_js.CSS2DObject(domElement);
3062
- super(app, obj);
3063
- this.obj = obj;
3064
- obj.center = center;
3082
+ constructor(app, domElement, center = new webgpu.Vector2(0.5, 1), uuid) {
3083
+ super(app, uuid);
3084
+ this.obj = new CSS2DRenderer_js.CSS2DObject(domElement);
3085
+ this.obj.center.copy(center);
3065
3086
  }
3066
3087
  set isHoverEnabled(bCanHorver) {
3067
3088
  return;
@@ -3331,6 +3352,7 @@ exports.FirstPerson = FirstPerson;
3331
3352
  exports.GeometryAssetPointer = GeometryAssetPointer;
3332
3353
  exports.LabelComponent = LabelComponent;
3333
3354
  exports.LevelActor = LevelActor;
3355
+ exports.LevelComponent = LevelComponent;
3334
3356
  exports.MaterialAssetPointer = MaterialAssetPointer;
3335
3357
  exports.MeshComponent = MeshComponent;
3336
3358
  exports.Orbital = Orbital;
@@ -1,4 +1,4 @@
1
- import { MathUtils, Group, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material, NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping, WebGPURenderer, PostProcessing, Color, Vector2, Raycaster, PerspectiveCamera, OrthographicCamera, Scene, Clock, DirectionalLight, MeshStandardMaterial, BoxGeometry, MeshBasicMaterial, PlaneGeometry, SphereGeometry, Object3D } from 'three/webgpu';
1
+ import { MathUtils, Object3D, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, LoadingManager, BufferGeometry, Texture, FileLoader, Material, NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping, WebGPURenderer, PostProcessing, Color, Vector2, Raycaster, PerspectiveCamera, OrthographicCamera, Clock, DirectionalLight, MeshStandardMaterial, BoxGeometry, PlaneGeometry, MeshBasicMaterial, SphereGeometry } from 'three/webgpu';
2
2
  import { GLTFLoader, DRACOLoader, CSS2DRenderer, OrbitControls } from 'three/examples/jsm/Addons.js';
3
3
  import { pass, mrt, output, uniform, velocity, metalness, transformedNormalView, blendColor, time, oscSine } from 'three/tsl';
4
4
  import { bloom } from 'three/examples/jsm/tsl/display/BloomNode.js';
@@ -12,7 +12,7 @@ import { motionBlur } from 'three/examples/jsm/tsl/display/MotionBlur.js';
12
12
  import { fxaa } from 'three/examples/jsm/tsl/display/FXAANode.js';
13
13
  import { smaa } from 'three/examples/jsm/tsl/display/SMAANode.js';
14
14
  import { gsap } from 'gsap';
15
- import { Mesh as Mesh$1 } from 'three';
15
+ import { Scene } from 'three';
16
16
  import { SkyMesh } from 'three/examples/jsm/objects/SkyMesh.js';
17
17
  import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
18
18
  import { PointerLockControls } from 'three/examples/jsm/controls/PointerLockControls';
@@ -83,14 +83,17 @@ class Component extends BaseObject {
83
83
  set name(name) {
84
84
  this._name = name;
85
85
  }
86
- constructor(newThreeObject) {
87
- super(newThreeObject.uuid);
86
+ constructor(uuid) {
87
+ super(uuid ? uuid : MathUtils.generateUUID());
88
88
  this.obj = null;
89
89
  this._parentActor = null;
90
90
  this._name = "Component";
91
91
  this._parentActor = null;
92
- this.threeObject = newThreeObject;
93
- this._name = `${newThreeObject.type}Component`;
92
+ this.threeObject = this.createDefaultObject();
93
+ this._name = `${this.threeObject.type}Component`;
94
+ }
95
+ createDefaultObject(_arg) {
96
+ return new Object3D();
94
97
  }
95
98
  destroyObject() {
96
99
  if (!this.obj) {
@@ -126,15 +129,15 @@ class SceneComponent extends Component {
126
129
  get world() {
127
130
  return this.app.world;
128
131
  }
129
- constructor(app, newThreeObject) {
130
- super(newThreeObject);
132
+ constructor(app, uuid) {
133
+ super(uuid);
131
134
  this.bCanHover = false;
132
135
  this.bCanClick = false;
133
136
  this.app = app;
134
- this._name = "SceneComponent";
137
+ this.name = "SceneComponent";
135
138
  }
136
- createDefaultThreeObject() {
137
- this.threeObject = new Group();
139
+ createDefaultObject() {
140
+ return new Object3D();
138
141
  }
139
142
  tick(deltaTime) {
140
143
  super.tick(deltaTime);
@@ -687,6 +690,9 @@ class SceneComponent extends Component {
687
690
 
688
691
  class MeshComponent extends SceneComponent {
689
692
  get threeObject() {
693
+ if (!this.obj) {
694
+ throw new Error("threeObject is null");
695
+ }
690
696
  return this.obj;
691
697
  }
692
698
  set threeObject(newThreeObject) {
@@ -765,7 +771,7 @@ class MeshComponent extends SceneComponent {
765
771
  }
766
772
  this._materialPtr = matPtrs;
767
773
  }
768
- constructor(app, geometry, material) {
774
+ constructor(app, geometry, material, uuid) {
769
775
  let matPtrs = [];
770
776
  let mats = Array.isArray(material) ? material : [material];
771
777
  mats.forEach((elem) => {
@@ -773,15 +779,18 @@ class MeshComponent extends SceneComponent {
773
779
  if (ptr)
774
780
  matPtrs.push(ptr);
775
781
  });
776
- let newMesh = new Mesh(geometry, material);
777
- super(app, newMesh);
782
+ super(app, uuid);
778
783
  this.obj = null;
779
784
  this._geometryPtr = app.assetManager.addGeometryAsset(geometry);
780
785
  this._materialPtr = matPtrs;
781
786
  matPtrs.forEach((elem) => {
782
787
  elem.addRef();
783
788
  });
784
- this.threeObject = newMesh;
789
+ this.threeObject.material = material;
790
+ this.threeObject.geometry = geometry;
791
+ }
792
+ createDefaultObject() {
793
+ return new Mesh();
785
794
  }
786
795
  set castShadow(bCast) {
787
796
  if (this.threeObject)
@@ -2358,8 +2367,8 @@ class Actor extends BaseObject {
2358
2367
  this.app.world.removeTickableActor(this);
2359
2368
  }
2360
2369
  }
2361
- constructor(app, myThreeObject = null) {
2362
- super();
2370
+ constructor(app, uuid) {
2371
+ super(uuid);
2363
2372
  this._name = "Actor";
2364
2373
  this._rootComponent = null;
2365
2374
  this._world = null;
@@ -2368,19 +2377,11 @@ class Actor extends BaseObject {
2368
2377
  this.onHoverBeginEvent = [];
2369
2378
  this.onHoverEndEvent = [];
2370
2379
  this.app = app;
2371
- this.constructRootComponent(myThreeObject);
2380
+ this.rootComponent = this.constructRootComponent();
2381
+ this.rootComponent.parentActor = this;
2372
2382
  }
2373
- constructRootComponent(myThreeObject = null) {
2374
- let tObject = myThreeObject ? myThreeObject : new Group();
2375
- if (tObject.isMesh) {
2376
- let mesh = tObject;
2377
- this._rootComponent = new MeshComponent(this.app, mesh.geometry, mesh.material);
2378
- this.rootComponent.parentActor = this;
2379
- }
2380
- else {
2381
- this._rootComponent = new SceneComponent(this.app, tObject);
2382
- this.rootComponent.parentActor = this;
2383
- }
2383
+ constructRootComponent() {
2384
+ return new SceneComponent(this.app);
2384
2385
  }
2385
2386
  getBoundsCenterPosition(bInWorldSpace = true) {
2386
2387
  let ret = new Vector3();
@@ -2702,6 +2703,27 @@ class ThreeObjectLibrary {
2702
2703
  }
2703
2704
  }
2704
2705
 
2706
+ class LevelComponent extends SceneComponent {
2707
+ get threeObject() {
2708
+ if (!this.obj) {
2709
+ throw Error("three object is invalid");
2710
+ }
2711
+ return this.obj;
2712
+ }
2713
+ set threeObject(newThreeObject) {
2714
+ this.obj = newThreeObject;
2715
+ if (this.obj) {
2716
+ this.obj.userData["LYObject"] = this;
2717
+ }
2718
+ }
2719
+ constructor(app, uuid) {
2720
+ super(app, uuid);
2721
+ }
2722
+ createDefaultObject() {
2723
+ return new Scene();
2724
+ }
2725
+ }
2726
+
2705
2727
  class LevelActor extends Actor {
2706
2728
  get scene() {
2707
2729
  if (!this._scene) {
@@ -2709,13 +2731,15 @@ class LevelActor extends Actor {
2709
2731
  }
2710
2732
  return this._scene;
2711
2733
  }
2712
- constructor(app) {
2713
- let scene = new Scene();
2714
- super(app, scene);
2734
+ constructor(app, uuid) {
2735
+ super(app, uuid);
2715
2736
  this._scene = null;
2716
- this._scene = scene;
2737
+ this._scene = this.rootComponent.threeObject;
2717
2738
  this.isTickEnabled = false;
2718
2739
  }
2740
+ constructRootComponent() {
2741
+ return new LevelComponent(this.app, this.uuid);
2742
+ }
2719
2743
  tick(_deltaTime) {
2720
2744
  if (!this.isTickEnabled) {
2721
2745
  return;
@@ -2724,13 +2748,14 @@ class LevelActor extends Actor {
2724
2748
  }
2725
2749
  destroy() {
2726
2750
  this.clearLevel();
2751
+ super.destroy();
2727
2752
  }
2728
2753
  clearLevel() {
2729
2754
  this.childActors.forEach((elem) => {
2730
2755
  elem.destroy();
2731
2756
  });
2732
2757
  this.scene.traverse((child) => {
2733
- if (child instanceof Mesh$1) {
2758
+ if (child instanceof Mesh) {
2734
2759
  ThreeObjectLibrary.disposeMeshResource(child);
2735
2760
  }
2736
2761
  });
@@ -2860,9 +2885,9 @@ class LightComponent extends SceneComponent {
2860
2885
  set intensity(intensity) {
2861
2886
  this.threeObject.intensity = intensity;
2862
2887
  }
2863
- constructor(app, light) {
2864
- super(app, light);
2865
- this.obj = light;
2888
+ constructor(app, uuid) {
2889
+ super(app, uuid);
2890
+ this.obj = null;
2866
2891
  }
2867
2892
  }
2868
2893
 
@@ -2885,11 +2910,14 @@ class DirectionalLightComponent extends LightComponent {
2885
2910
  set castShadow(value) {
2886
2911
  this.threeObject.castShadow = value;
2887
2912
  }
2888
- constructor(app, color = 0xffffff, intensity = 10) {
2889
- let obj = new DirectionalLight(color, intensity);
2890
- super(app, obj);
2891
- this.obj = obj;
2892
- obj.castShadow = true;
2913
+ constructor(app, color = 0xffffff, intensity = 10, uuid) {
2914
+ super(app, uuid);
2915
+ this.obj = null;
2916
+ this.threeObject.color.set(color);
2917
+ this.threeObject.intensity = intensity;
2918
+ }
2919
+ createDefaultObject() {
2920
+ return new DirectionalLight(0xffffff, 10);
2893
2921
  }
2894
2922
  setPosition(...args) {
2895
2923
  if (args.length === 1) {
@@ -2916,34 +2944,34 @@ class DirectionalLightComponent extends LightComponent {
2916
2944
  }
2917
2945
 
2918
2946
  class DirectionalLightActor extends Actor {
2919
- constructor(app, color = 0xffffff, intensity = 1) {
2920
- super(app);
2947
+ constructor(app, color = 0xffffff, intensity = 1, uuid) {
2948
+ super(app, uuid);
2921
2949
  this.lightComponent = null;
2922
2950
  this.lightComponent = this.rootComponent;
2923
2951
  if (this.lightComponent) {
2924
2952
  this.lightComponent.color = color;
2925
2953
  this.lightComponent.intensity = intensity;
2954
+ this.lightComponent.castShadow = true;
2926
2955
  }
2927
2956
  this.lightComponent.castShadow = true;
2928
2957
  }
2929
2958
  constructRootComponent() {
2930
- this.lightComponent = new DirectionalLightComponent(this.app);
2931
- this.rootComponent = this.lightComponent;
2932
- this.lightComponent.castShadow = true;
2933
- this.rootComponent.parentActor = this;
2959
+ return new DirectionalLightComponent(this.app);
2934
2960
  }
2935
2961
  }
2936
2962
 
2937
2963
  class BoxComponent extends MeshComponent {
2938
- constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshStandardMaterial()) {
2939
- super(app, new BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material);
2964
+ constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshStandardMaterial(), uuid) {
2965
+ super(app, new BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
2940
2966
  }
2941
2967
  }
2942
2968
 
2943
2969
  class BoxActor extends Actor {
2944
- constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshBasicMaterial()) {
2945
- super(app);
2946
- this.addComponent(new BoxComponent(this.app, width, height, depth, widthSegments, heightSegments, depthSegments, material));
2970
+ constructor(app, uuid) {
2971
+ super(app, uuid);
2972
+ }
2973
+ constructRootComponent() {
2974
+ this.rootComponent = new BoxComponent(this.app);
2947
2975
  }
2948
2976
  }
2949
2977
 
@@ -2968,18 +2996,19 @@ class SkyComponent extends SceneComponent {
2968
2996
  this.obj.userData["LYObject"] = this;
2969
2997
  }
2970
2998
  }
2971
- constructor(app, skyparam) {
2972
- let obj = new SkyMesh();
2973
- super(app, obj);
2999
+ constructor(app, skyparam, uuid) {
3000
+ super(app, uuid);
3001
+ this.obj = null;
2974
3002
  this.skyParam = DefaultSkyParam;
2975
3003
  this.sunPosition = new Vector3();
2976
- this.obj = obj;
2977
- this.name = "SkyComponent";
2978
3004
  if (skyparam) {
2979
3005
  this.skyParam = skyparam;
2980
3006
  }
2981
3007
  this.updateSky();
2982
3008
  }
3009
+ createDefaultObject() {
3010
+ return new SkyMesh();
3011
+ }
2983
3012
  updateSky() {
2984
3013
  var _a, _b;
2985
3014
  this.threeObject.turbidity.value = this.skyParam.turbidity;
@@ -2993,7 +3022,9 @@ class SkyComponent extends SceneComponent {
2993
3022
  (_b = (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport) === null || _b === void 0 ? void 0 : _b.markRenderStateDirty();
2994
3023
  }
2995
3024
  destroyObject() {
2996
- ThreeObjectLibrary.disposeMeshResource(this.obj);
3025
+ if (this.obj) {
3026
+ ThreeObjectLibrary.disposeMeshResource(this.obj);
3027
+ }
2997
3028
  }
2998
3029
  }
2999
3030
 
@@ -3008,40 +3039,31 @@ class SkyActor extends Actor {
3008
3039
  this.setScale(45000, 45000, 45000);
3009
3040
  }
3010
3041
  constructRootComponent() {
3011
- this.skyComponent = new SkyComponent(this.app);
3012
- this.rootComponent = this.skyComponent;
3013
- this.rootComponent.parentActor = this;
3042
+ return new SkyComponent(this.app);
3014
3043
  }
3015
3044
  }
3016
3045
 
3017
3046
  class PlaneComponent extends MeshComponent {
3018
- constructor(app, width, height, material, widthSegments = 1, heightSegments = 1) {
3019
- super(app, new PlaneGeometry(width, height, widthSegments, heightSegments), material);
3047
+ constructor(app, width, height, material, widthSegments = 1, heightSegments = 1, uuid) {
3048
+ super(app, new PlaneGeometry(width, height, widthSegments, heightSegments), material, uuid);
3020
3049
  }
3021
3050
  }
3022
3051
 
3023
3052
  class PlaneActor extends Actor {
3024
- get planeComponent() {
3025
- return this._planeComponent;
3053
+ constructor(app, uuid) {
3054
+ super(app, uuid);
3026
3055
  }
3027
- constructor(app, width, height, material = new MeshBasicMaterial(), widthSegments = 1, heightSegments = 1) {
3028
- super(app);
3029
- this._planeComponent = new PlaneComponent(this.app, width, height, material, widthSegments, heightSegments);
3030
- this._planeComponent.setRotation(Math.PI * 0.5 * -1, 0, 0);
3031
- this.addComponent(this._planeComponent);
3032
- this._planeComponent.receiveShadow = true;
3056
+ constructRootComponent() {
3057
+ return new PlaneComponent(this.app, 1, 1, new MeshBasicMaterial(), 1, 1, this.uuid);
3033
3058
  }
3034
3059
  destroy() {
3035
- var _a;
3036
- (_a = this._planeComponent) === null || _a === void 0 ? void 0 : _a.destroy();
3037
- this._planeComponent = null;
3038
3060
  super.destroy();
3039
3061
  }
3040
3062
  }
3041
3063
 
3042
3064
  class SphereComponent extends MeshComponent {
3043
- constructor(app, radius, material = new MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
3044
- super(app, new SphereGeometry(radius, widthSegments, heightSegments), material);
3065
+ constructor(app, radius, material = new MeshBasicMaterial(), widthSegments = 32, heightSegments = 16, uuid) {
3066
+ super(app, new SphereGeometry(radius, widthSegments, heightSegments), material, uuid);
3045
3067
  }
3046
3068
  }
3047
3069
 
@@ -3055,11 +3077,10 @@ class LabelComponent extends SceneComponent {
3055
3077
  this.obj.userData["LYObject"] = this;
3056
3078
  }
3057
3079
  }
3058
- constructor(app, domElement, center = new Vector2(0.5, 1)) {
3059
- let obj = new CSS2DObject(domElement);
3060
- super(app, obj);
3061
- this.obj = obj;
3062
- obj.center = center;
3080
+ constructor(app, domElement, center = new Vector2(0.5, 1), uuid) {
3081
+ super(app, uuid);
3082
+ this.obj = new CSS2DObject(domElement);
3083
+ this.obj.center.copy(center);
3063
3084
  }
3064
3085
  set isHoverEnabled(bCanHorver) {
3065
3086
  return;
@@ -3303,4 +3324,4 @@ class TransformGizmo extends Pawn {
3303
3324
  }
3304
3325
  }
3305
3326
 
3306
- export { Actor, AssetManager, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOutlineParams, DefaultPostProcessParam, DefaultRenderParam, DefaultSSRParam, DefaultSkyParam, DefaultToneMappingParams, DefaultViewportParam, DefaultWorldParam, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, GeometryAssetPointer, LabelComponent, LevelActor, MaterialAssetPointer, MeshComponent, Orbital, PlaneActor, PlaneComponent, SceneComponent, SkyActor, SkyComponent, SphereComponent, TAssetPointer, TSmartPointer, TextureAssetPointer, ThreeJsApp, ThreeObjectLibrary, ToneMappingOptions, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
3327
+ export { Actor, AssetManager, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOutlineParams, DefaultPostProcessParam, DefaultRenderParam, DefaultSSRParam, DefaultSkyParam, DefaultToneMappingParams, DefaultViewportParam, DefaultWorldParam, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, GeometryAssetPointer, LabelComponent, LevelActor, LevelComponent, MaterialAssetPointer, MeshComponent, Orbital, PlaneActor, PlaneComponent, SceneComponent, SkyActor, SkyComponent, SphereComponent, TAssetPointer, TSmartPointer, TextureAssetPointer, ThreeJsApp, ThreeObjectLibrary, ToneMappingOptions, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export { MeshComponent } from "./lythreeframe/Object/Components/Mesh/MeshCompone
29
29
  export { BoxComponent } from "./lythreeframe/Object/Components/Mesh/Shape/BoxComponent";
30
30
  export { PlaneComponent } from "./lythreeframe/Object/Components/Mesh/Shape/PlaneComponent";
31
31
  export { SphereComponent } from "./lythreeframe/Object/Components/Mesh/Shape/SphereComponent";
32
+ export { LevelComponent } from "./lythreeframe/Object/Components/Level/LevelComponent";
32
33
  export { DirectionalLightComponent } from "./lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent";
33
34
  export { LabelComponent } from "./lythreeframe/Object/Components/2D/2DComponent";
34
35
  export { SkyComponent } from "./lythreeframe/Object/Components/Sky/SkyComponent";
@@ -2,7 +2,7 @@ import { BufferGeometry, LoadingManager, Material, Mesh, Texture } from "three/w
2
2
  import { SceneComponent } from "../Object/Components/SceneComponent";
3
3
  import { TAssetPointer } from "./AssetPointer/AssetPointer";
4
4
  import { DRACOLoader, GLTF, GLTFLoader } from 'three/examples/jsm/Addons.js';
5
- import { Object3D } from "three";
5
+ import { Object3D } from "three/webgpu";
6
6
  import { ThreeJsApp } from "../ThreeJsApp";
7
7
  import { MaterialAssetPointer } from "./AssetPointer/Assets/MaterialAssetPointer";
8
8
  import { TextureAssetPointer } from "./AssetPointer/Assets/TextureAssetPointer";
@@ -1,6 +1,6 @@
1
1
  import { OrthographicCamera, PerspectiveCamera } from "three/webgpu";
2
2
  import { CameraParam } from "../Frame/Parameters/CameraParameter";
3
3
  export declare class CameraFactory {
4
- static createCamera(param: CameraParam): any;
4
+ static createCamera(param: CameraParam): PerspectiveCamera | OrthographicCamera;
5
5
  static updataCamera(param: CameraParam, camera: PerspectiveCamera | OrthographicCamera): PerspectiveCamera | OrthographicCamera;
6
6
  }
@@ -1,4 +1,4 @@
1
- import { Vector3, Quaternion, Object3D, Box3, Euler } from "three/webgpu";
1
+ import { Vector3, Quaternion, Object3D, Box3, Plane, Euler } from "three/webgpu";
2
2
  export interface Segment {
3
3
  pointA: Vector3;
4
4
  pointB: Vector3;
@@ -11,8 +11,8 @@ export declare class LYMath {
11
11
  y: number;
12
12
  z: number;
13
13
  };
14
- static getQuatFromAxis(forwardVector: Vector3, upVector?: Vector3): any;
15
- static MaxVector(v1: Vector3, v2: Vector3): any;
14
+ static getQuatFromAxis(forwardVector: Vector3, upVector?: Vector3): Quaternion;
15
+ static MaxVector(v1: Vector3, v2: Vector3): Vector3;
16
16
  static clamp(value: number, min: number, max: number): number;
17
17
  static getPlaneConstantFromPointAndNormal(point: Vector3, normal: Vector3): number;
18
18
  static getSizeAndCenterOfObject3D(object: Object3D): {
@@ -22,6 +22,6 @@ export declare class LYMath {
22
22
  };
23
23
  static SegmentsIntersection(segmentA: Segment, segmentB: Segment): Vector3 | null;
24
24
  static getCenterPointInPoints(points: Vector3[]): Vector3;
25
- static contructPlane(dirction: Vector3, position: Vector3, quaternion: Quaternion, scale: Vector3): any;
26
- static intersectRayPlane(rayOrigin: Vector3, rayDirection: Vector3, planeNormal: Vector3, planePoint: Vector3): any;
25
+ static contructPlane(dirction: Vector3, position: Vector3, quaternion: Quaternion, scale: Vector3): Plane;
26
+ static intersectRayPlane(rayOrigin: Vector3, rayDirection: Vector3, planeNormal: Vector3, planePoint: Vector3): Vector3 | null;
27
27
  }
@@ -1,4 +1,4 @@
1
- import { Vector3, Quaternion, Euler, Matrix4, Object3D } from "three/webgpu";
1
+ import { Vector3, Quaternion, Euler, Matrix4 } from "three/webgpu";
2
2
  import { BaseObject } from "./BaseObject";
3
3
  import { AttachmentRules } from "../Defines";
4
4
  import { SceneComponent } from "./Components/SceneComponent";
@@ -23,12 +23,12 @@ export declare class Actor extends BaseObject {
23
23
  protected onDoubleClickedEvent: ((component?: SceneComponent) => void)[];
24
24
  protected onHoverBeginEvent: ((component?: SceneComponent) => void)[];
25
25
  protected onHoverEndEvent: ((component?: SceneComponent) => void)[];
26
- constructor(app: ThreeJsApp, myThreeObject?: Object3D | null);
27
- protected constructRootComponent(myThreeObject?: Object3D | null): void;
28
- getBoundsCenterPosition(bInWorldSpace?: boolean): any;
29
- getBoundsTopCenterPosition(bInWorldSpace?: boolean): any;
30
- getBoundsBottomCenterPosition(bInWorldSpace?: boolean): any;
31
- getBounds(): Box3;
26
+ constructor(app: ThreeJsApp, uuid?: string);
27
+ protected constructRootComponent(): SceneComponent;
28
+ getBoundsCenterPosition(bInWorldSpace?: boolean): Vector3;
29
+ getBoundsTopCenterPosition(bInWorldSpace?: boolean): Vector3;
30
+ getBoundsBottomCenterPosition(bInWorldSpace?: boolean): Vector3;
31
+ getBounds(): import("three").Box3;
32
32
  destroy(): void;
33
33
  setVisible(bVisible: boolean): void;
34
34
  setLayers(layer: number, bAffectChildActor?: boolean): void;
@@ -1,10 +1,12 @@
1
1
  import { Scene } from "three/webgpu";
2
2
  import { ThreeJsApp } from "../../../ThreeJsApp";
3
3
  import { Actor } from "../../Actor";
4
+ import { LevelComponent } from "../../Components/Level/LevelComponent";
4
5
  export declare class LevelActor extends Actor {
5
6
  get scene(): Scene;
6
7
  protected _scene: Scene | null;
7
- constructor(app: ThreeJsApp);
8
+ constructor(app: ThreeJsApp, uuid?: string);
9
+ protected constructRootComponent(): LevelComponent;
8
10
  tick(_deltaTime: number): void;
9
11
  destroy(): void;
10
12
  clearLevel(): void;
@@ -4,6 +4,6 @@ import { DirectionalLightComponent } from "../../Components/Light/DirectionalLig
4
4
  import { ThreeJsApp } from "../../../ThreeJsApp";
5
5
  export declare class DirectionalLightActor extends Actor {
6
6
  protected lightComponent: DirectionalLightComponent | null;
7
- constructor(app: ThreeJsApp, color?: ColorRepresentation, intensity?: number);
8
- protected constructRootComponent(): void;
7
+ constructor(app: ThreeJsApp, color?: ColorRepresentation, intensity?: number, uuid?: string);
8
+ protected constructRootComponent(): DirectionalLightComponent;
9
9
  }
@@ -1,6 +1,6 @@
1
- import { Material } from "three/webgpu";
2
1
  import { Actor } from "../../Actor";
3
2
  import { ThreeJsApp } from "../../../ThreeJsApp";
4
3
  export declare class BoxActor extends Actor {
5
- constructor(app: ThreeJsApp, width?: number, height?: number, depth?: number, widthSegments?: number, heightSegments?: number, depthSegments?: number, material?: Material);
4
+ constructor(app: ThreeJsApp, uuid?: string);
5
+ protected constructRootComponent(): void;
6
6
  }
@@ -1,10 +1,8 @@
1
- import { Material } from "three/webgpu";
2
1
  import { Actor } from "../../Actor";
3
2
  import { PlaneComponent } from "../../Components/Mesh/Shape/PlaneComponent";
4
3
  import { ThreeJsApp } from "../../../ThreeJsApp";
5
4
  export declare class PlaneActor extends Actor {
6
- get planeComponent(): PlaneComponent | null;
7
- private _planeComponent;
8
- constructor(app: ThreeJsApp, width: number, height: number, material?: Material, widthSegments?: number, heightSegments?: number);
5
+ constructor(app: ThreeJsApp, uuid?: string);
6
+ protected constructRootComponent(): PlaneComponent;
9
7
  destroy(): void;
10
8
  }
@@ -5,5 +5,5 @@ export declare class SkyActor extends Actor {
5
5
  protected _name: string;
6
6
  protected skyComponent: SkyComponent | null;
7
7
  constructor(app: ThreeJsApp);
8
- protected constructRootComponent(): void;
8
+ protected constructRootComponent(): SkyComponent;
9
9
  }
@@ -1,11 +1,12 @@
1
1
  import { CSS2DObject } from "three/examples/jsm/renderers/CSS2DRenderer.js";
2
+ import { Vector2 } from "three/webgpu";
2
3
  import { SceneComponent } from "../SceneComponent";
3
4
  import { ThreeJsApp } from "../../../ThreeJsApp";
4
5
  export declare class LabelComponent extends SceneComponent {
5
6
  get threeObject(): CSS2DObject;
6
7
  set threeObject(newThreeObject: CSS2DObject);
7
8
  protected obj: CSS2DObject;
8
- constructor(app: ThreeJsApp, domElement: HTMLElement, center?: any);
9
+ constructor(app: ThreeJsApp, domElement: HTMLElement, center?: Vector2, uuid?: string);
9
10
  set isHoverEnabled(bCanHorver: boolean);
10
11
  set isClickEnabled(bCanClick: boolean);
11
12
  setVisible(bVisible: boolean): void;
@@ -11,7 +11,8 @@ export declare abstract class Component extends BaseObject {
11
11
  protected obj: Object3D | null;
12
12
  protected _parentActor: Actor | null;
13
13
  protected _name: string;
14
- protected constructor(newThreeObject: Object3D);
14
+ protected constructor(uuid?: string);
15
+ protected createDefaultObject(_arg?: any): Object3D;
15
16
  destroyObject(): void;
16
17
  destroy(): void;
17
18
  }
@@ -0,0 +1,9 @@
1
+ import { Scene } from "three";
2
+ import { SceneComponent } from "../SceneComponent";
3
+ import { ThreeJsApp } from "../../../ThreeJsApp";
4
+ export declare class LevelComponent extends SceneComponent {
5
+ get threeObject(): Scene;
6
+ protected set threeObject(newThreeObject: Scene);
7
+ constructor(app: ThreeJsApp, uuid?: string);
8
+ protected createDefaultObject(): Scene;
9
+ }
@@ -8,7 +8,8 @@ export declare class DirectionalLightComponent extends LightComponent {
8
8
  get castShadow(): boolean;
9
9
  set castShadow(value: boolean);
10
10
  protected obj: DirectionalLight | null;
11
- constructor(app: ThreeJsApp, color?: ColorRepresentation, intensity?: number);
11
+ constructor(app: ThreeJsApp, color?: ColorRepresentation, intensity?: number, uuid?: string);
12
+ protected createDefaultObject(): DirectionalLight;
12
13
  setPosition(...args: [Vector3] | [number, number, number]): void;
13
14
  update(): void;
14
15
  onAddedToWorld(world: World): void;
@@ -9,5 +9,5 @@ export declare abstract class LightComponent extends SceneComponent {
9
9
  get intensity(): number;
10
10
  set intensity(intensity: number);
11
11
  protected obj: Light | null;
12
- protected constructor(app: ThreeJsApp, light: Light);
12
+ protected constructor(app: ThreeJsApp, uuid?: string);
13
13
  }
@@ -3,7 +3,7 @@ import { SceneComponent } from "../SceneComponent";
3
3
  import { TAssetPointer } from "../../../AssetManagement/AssetPointer/AssetPointer";
4
4
  import { ThreeJsApp } from "../../../ThreeJsApp";
5
5
  export declare class MeshComponent extends SceneComponent {
6
- get threeObject(): Mesh | null;
6
+ get threeObject(): Mesh;
7
7
  set threeObject(newThreeObject: Mesh);
8
8
  protected obj: Mesh | null;
9
9
  get geometry(): BufferGeometry | null;
@@ -16,7 +16,8 @@ export declare class MeshComponent extends SceneComponent {
16
16
  set materialPtr(newMat: TAssetPointer<Material> | TAssetPointer<Material>[]);
17
17
  protected _geometryPtr: TAssetPointer<BufferGeometry> | null;
18
18
  protected _materialPtr: TAssetPointer<Material>[];
19
- constructor(app: ThreeJsApp, geometry: BufferGeometry, material: Material | Material[]);
19
+ constructor(app: ThreeJsApp, geometry: BufferGeometry, material: Material | Material[], uuid?: string);
20
+ protected createDefaultObject(): Mesh;
20
21
  set castShadow(bCast: boolean);
21
22
  get castShadow(): boolean;
22
23
  set receiveShadow(bReceive: boolean);
@@ -2,5 +2,5 @@ import { Material } from "three/webgpu";
2
2
  import { MeshComponent } from "../MeshComponent";
3
3
  import { ThreeJsApp } from "../../../../ThreeJsApp";
4
4
  export declare class BoxComponent extends MeshComponent {
5
- constructor(app: ThreeJsApp, width?: number, height?: number, depth?: number, widthSegments?: number, heightSegments?: number, depthSegments?: number, material?: Material);
5
+ constructor(app: ThreeJsApp, width?: number, height?: number, depth?: number, widthSegments?: number, heightSegments?: number, depthSegments?: number, material?: Material, uuid?: string);
6
6
  }
@@ -2,5 +2,5 @@ import { Material } from "three/webgpu";
2
2
  import { MeshComponent } from "../MeshComponent";
3
3
  import { ThreeJsApp } from "../../../../ThreeJsApp";
4
4
  export declare class PlaneComponent extends MeshComponent {
5
- constructor(app: ThreeJsApp, width: number, height: number, material: Material, widthSegments?: number, heightSegments?: number);
5
+ constructor(app: ThreeJsApp, width: number, height: number, material: Material, widthSegments?: number, heightSegments?: number, uuid?: string);
6
6
  }
@@ -1,5 +1,6 @@
1
+ import { MeshBasicMaterial } from "three/webgpu";
1
2
  import { MeshComponent } from "../MeshComponent";
2
3
  import { ThreeJsApp } from "../../../../ThreeJsApp";
3
4
  export declare class SphereComponent extends MeshComponent {
4
- constructor(app: ThreeJsApp, radius: number, material?: any, widthSegments?: number, heightSegments?: number);
5
+ constructor(app: ThreeJsApp, radius: number, material?: MeshBasicMaterial, widthSegments?: number, heightSegments?: number, uuid?: string);
5
6
  }
@@ -11,8 +11,8 @@ export declare class SceneComponent extends Component {
11
11
  protected bCanClick: boolean;
12
12
  get world(): World;
13
13
  protected app: ThreeJsApp;
14
- constructor(app: ThreeJsApp, newThreeObject: Object3D);
15
- createDefaultThreeObject(): void;
14
+ constructor(app: ThreeJsApp, uuid?: string);
15
+ protected createDefaultObject(): Object3D;
16
16
  tick(deltaTime: number): void;
17
17
  get isVisible(): boolean;
18
18
  setVisible(bVisible: boolean): void;
@@ -26,29 +26,29 @@ export declare class SceneComponent extends Component {
26
26
  onAddedToWorld(world: World): void;
27
27
  destroy(): void;
28
28
  destroyObject(): void;
29
- getPosition(): any;
29
+ getPosition(): Vector3;
30
30
  setPosition(position: Vector3): void;
31
31
  setPosition(x: number, y: number, z: number): void;
32
- getRotation(): any;
32
+ getRotation(): Euler;
33
33
  setRotation(rotation: Euler): void;
34
34
  setRotation(x: number, y: number, z: number): void;
35
- getQuaternion(): any;
35
+ getQuaternion(): Quaternion;
36
36
  setQuaternion(quat: Quaternion): void;
37
37
  setQuaternion(x: number, y: number, z: number, w: number): void;
38
- getScale(): any;
38
+ getScale(): Vector3;
39
39
  setScale(position: Vector3): void;
40
40
  setScale(x: number, y: number, z: number): void;
41
41
  getMatrix(): Matrix4;
42
42
  setMatrix(matrix: Matrix4): void;
43
- getWorldPosition(): any;
44
- getWorldRotation(): any;
45
- getWorldQuaternion(): any;
46
- getWorldScale(): any;
47
- getWorldMatrix(): any;
43
+ getWorldPosition(): Vector3;
44
+ getWorldRotation(): Euler;
45
+ getWorldQuaternion(): Quaternion;
46
+ getWorldScale(): Vector3;
47
+ getWorldMatrix(): Matrix4;
48
48
  setWorldMatrix(newMatrix: Matrix4): void;
49
- getWorldForwardDirection(): any;
50
- getWorldUpDirection(): any;
51
- getWorldRightDirection(): any;
49
+ getWorldForwardDirection(): Vector3;
50
+ getWorldUpDirection(): Vector3;
51
+ getWorldRightDirection(): Vector3;
52
52
  worldToLocal(vec: Vector3): Vector3;
53
53
  localToWorld(vec: Vector3): Vector3;
54
54
  attachComponent(newComponent: SceneComponent): void;
@@ -16,7 +16,8 @@ export declare class SkyComponent extends SceneComponent {
16
16
  protected obj: SkyMesh | null;
17
17
  private skyParam;
18
18
  private sunPosition;
19
- constructor(app: ThreeJsApp, skyparam?: SkyComponentParam);
19
+ constructor(app: ThreeJsApp, skyparam?: SkyComponentParam, uuid?: string);
20
+ protected createDefaultObject(): SkyMesh;
20
21
  private updateSky;
21
22
  destroyObject(): void;
22
23
  }
@@ -7,7 +7,7 @@ export declare class Orbital extends Pawn {
7
7
  get control(): OrbitControls;
8
8
  protected _control: OrbitControls;
9
9
  protected changeEvent: () => void;
10
- get camera(): any;
10
+ get camera(): import("three").PerspectiveCamera | import("three").OrthographicCamera;
11
11
  constructor(controller: Controller);
12
12
  possess(): void;
13
13
  unpossess(): void;
@@ -1,7 +1,7 @@
1
1
  import { Euler, Quaternion, Vector3 } from "three/webgpu";
2
2
  import { Controller } from "../../Frame/Controller";
3
3
  export declare abstract class Pawn {
4
- get camera(): any;
4
+ get camera(): import("three").PerspectiveCamera | import("three").OrthographicCamera;
5
5
  set enabled(value: boolean);
6
6
  get control(): any;
7
7
  protected _control: any | null;
@@ -6,4 +6,4 @@ export declare const DefaultToneMappingParams: {
6
6
  exposure: number;
7
7
  toneMapping: string;
8
8
  };
9
- export declare const ToneMappingOptions: Map<string, any>;
9
+ export declare const ToneMappingOptions: Map<string, 0 | 1 | 2 | 3 | 4 | 6 | 7>;
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
- {
2
- "name": "lythreeframe",
3
- "version": "1.1.19",
4
- "description": "Three.js 封装",
5
- "main": "dist/bundle.cjs.js",
6
- "module": "dist/bundle.esm.js",
7
- "type": "module",
8
- "types": "dist/index.d.ts",
9
- "scripts": {
10
- "build": "rollup -c",
11
- "prepublishOnly": "npm run build"
12
- },
13
- "peerDependencies": {
14
- "gsap": "^3.12.2",
15
- "three": "^0.174.0",
16
- "@types/three": "^0.174.0"
17
- },
18
- "files": [
19
- "dist"
20
- ],
21
- "devDependencies": {
22
- "@rollup/plugin-typescript": "^12.1.2",
23
- "@types/three": "^0.174.0",
24
- "gsap": "^3.12.2",
25
- "rollup": "^4.35.0",
26
- "three": "^0.174.0",
27
- "tslib": "^2.8.1",
28
- "typescript": "^5.8.2"
29
- },
30
- "keywords": [
31
- "three.js",
32
- "webgl",
33
- "3d",
34
- "graphics",
35
- "webgpu"
36
- ],
37
- "author": "notimportant",
38
- "license": "MIT"
39
- }
1
+ {
2
+ "name": "lythreeframe",
3
+ "version": "1.2.0",
4
+ "description": "Three.js 封装",
5
+ "main": "dist/bundle.cjs.js",
6
+ "module": "dist/bundle.esm.js",
7
+ "type": "module",
8
+ "types": "dist/index.d.ts",
9
+ "scripts": {
10
+ "build": "rollup -c",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "peerDependencies": {
14
+ "@types/three": "^0.175.0",
15
+ "gsap": "^3.12.2",
16
+ "three": "^0.175.0"
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "devDependencies": {
22
+ "@rollup/plugin-typescript": "^12.1.2",
23
+ "@types/three": "^0.175.0",
24
+ "gsap": "^3.12.2",
25
+ "rollup": "^4.35.0",
26
+ "three": "^0.175.0",
27
+ "tslib": "^2.8.1",
28
+ "typescript": "^5.8.2"
29
+ },
30
+ "keywords": [
31
+ "three.js",
32
+ "webgl",
33
+ "3d",
34
+ "graphics",
35
+ "webgpu"
36
+ ],
37
+ "author": "notimportant",
38
+ "license": "MIT"
39
+ }