lythreeframe 1.1.19 → 1.2.1

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 (29) hide show
  1. package/dist/bundle.cjs.js +109 -86
  2. package/dist/bundle.esm.js +110 -88
  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/Frame/Parameters/AppParameter.d.ts +1 -1
  7. package/dist/lythreeframe/Library/Math.d.ts +5 -5
  8. package/dist/lythreeframe/Object/Actor.d.ts +7 -7
  9. package/dist/lythreeframe/Object/Actors/Level/LevelActor.d.ts +3 -1
  10. package/dist/lythreeframe/Object/Actors/Light/DirectionalLightActor.d.ts +2 -2
  11. package/dist/lythreeframe/Object/Actors/Shape/BoxActor.d.ts +3 -2
  12. package/dist/lythreeframe/Object/Actors/Shape/PlaneActor.d.ts +2 -4
  13. package/dist/lythreeframe/Object/Actors/Sky/SkyActor.d.ts +1 -1
  14. package/dist/lythreeframe/Object/Components/2D/2DComponent.d.ts +2 -1
  15. package/dist/lythreeframe/Object/Components/Component.d.ts +2 -1
  16. package/dist/lythreeframe/Object/Components/Level/LevelComponent.d.ts +9 -0
  17. package/dist/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.d.ts +2 -1
  18. package/dist/lythreeframe/Object/Components/Light/LightComponent.d.ts +1 -1
  19. package/dist/lythreeframe/Object/Components/Mesh/MeshComponent.d.ts +3 -2
  20. package/dist/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.d.ts +1 -1
  21. package/dist/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.d.ts +1 -1
  22. package/dist/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.d.ts +2 -1
  23. package/dist/lythreeframe/Object/Components/Mesh/Sprite/SpriteComponent.d.ts +2 -2
  24. package/dist/lythreeframe/Object/Components/SceneComponent.d.ts +14 -14
  25. package/dist/lythreeframe/Object/Components/Sky/SkyComponent.d.ts +2 -1
  26. package/dist/lythreeframe/Object/PawnV2/Oribital.d.ts +1 -1
  27. package/dist/lythreeframe/Object/PawnV2/Pawn.d.ts +1 -1
  28. package/dist/lythreeframe/PostProcess/Param/ToneMapping.d.ts +1 -1
  29. package/package.json +39 -39
@@ -17,7 +17,7 @@ var gsap = require('gsap');
17
17
  var three = require('three');
18
18
  var SkyMesh_js = require('three/examples/jsm/objects/SkyMesh.js');
19
19
  var CSS2DRenderer_js = require('three/examples/jsm/renderers/CSS2DRenderer.js');
20
- var PointerLockControls = require('three/examples/jsm/controls/PointerLockControls');
20
+ var PointerLockControls_js = require('three/examples/jsm/controls/PointerLockControls.js');
21
21
  var TransformControls_js = require('three/examples/jsm/controls/TransformControls.js');
22
22
 
23
23
  /*
@@ -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)
@@ -920,7 +929,8 @@ class MaterialAssetPointer extends TAssetPointer {
920
929
  }
921
930
  try {
922
931
  this.textures.set(name, texturePtr);
923
- this.getValue()[name] = texture;
932
+ const matAny = mat;
933
+ matAny[name] = texture;
924
934
  texturePtr.addRef();
925
935
  mat.needsUpdate = true;
926
936
  }
@@ -1150,8 +1160,9 @@ class AssetManager {
1150
1160
  if (!pointer) {
1151
1161
  let textureMap = new Map();
1152
1162
  for (let k in asset) {
1153
- if (asset[k] instanceof webgpu.Texture) {
1154
- let ptr = this.addTextureAsset(asset[k], 1);
1163
+ const value = asset[k];
1164
+ if (value instanceof webgpu.Texture) {
1165
+ let ptr = this.addTextureAsset(value, 1);
1155
1166
  textureMap.set(k, ptr);
1156
1167
  }
1157
1168
  }
@@ -1731,7 +1742,6 @@ class Viewport {
1731
1742
  this.smaaPass = null;
1732
1743
  }
1733
1744
  }
1734
- console.log(this.postProcessParam, "sssssssssssssssssssss");
1735
1745
  this.postProcessing.outputNode = finalNode;
1736
1746
  this.markRenderStateDirty();
1737
1747
  }
@@ -2360,8 +2370,8 @@ class Actor extends BaseObject {
2360
2370
  this.app.world.removeTickableActor(this);
2361
2371
  }
2362
2372
  }
2363
- constructor(app, myThreeObject = null) {
2364
- super();
2373
+ constructor(app, uuid) {
2374
+ super(uuid);
2365
2375
  this._name = "Actor";
2366
2376
  this._rootComponent = null;
2367
2377
  this._world = null;
@@ -2370,19 +2380,11 @@ class Actor extends BaseObject {
2370
2380
  this.onHoverBeginEvent = [];
2371
2381
  this.onHoverEndEvent = [];
2372
2382
  this.app = app;
2373
- this.constructRootComponent(myThreeObject);
2383
+ this.rootComponent = this.constructRootComponent();
2384
+ this.rootComponent.parentActor = this;
2374
2385
  }
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
- }
2386
+ constructRootComponent() {
2387
+ return new SceneComponent(this.app);
2386
2388
  }
2387
2389
  getBoundsCenterPosition(bInWorldSpace = true) {
2388
2390
  let ret = new webgpu.Vector3();
@@ -2704,6 +2706,27 @@ class ThreeObjectLibrary {
2704
2706
  }
2705
2707
  }
2706
2708
 
2709
+ class LevelComponent extends SceneComponent {
2710
+ get threeObject() {
2711
+ if (!this.obj) {
2712
+ throw Error("three object is invalid");
2713
+ }
2714
+ return this.obj;
2715
+ }
2716
+ set threeObject(newThreeObject) {
2717
+ this.obj = newThreeObject;
2718
+ if (this.obj) {
2719
+ this.obj.userData["LYObject"] = this;
2720
+ }
2721
+ }
2722
+ constructor(app, uuid) {
2723
+ super(app, uuid);
2724
+ }
2725
+ createDefaultObject() {
2726
+ return new three.Scene();
2727
+ }
2728
+ }
2729
+
2707
2730
  class LevelActor extends Actor {
2708
2731
  get scene() {
2709
2732
  if (!this._scene) {
@@ -2711,13 +2734,15 @@ class LevelActor extends Actor {
2711
2734
  }
2712
2735
  return this._scene;
2713
2736
  }
2714
- constructor(app) {
2715
- let scene = new webgpu.Scene();
2716
- super(app, scene);
2737
+ constructor(app, uuid) {
2738
+ super(app, uuid);
2717
2739
  this._scene = null;
2718
- this._scene = scene;
2740
+ this._scene = this.rootComponent.threeObject;
2719
2741
  this.isTickEnabled = false;
2720
2742
  }
2743
+ constructRootComponent() {
2744
+ return new LevelComponent(this.app, this.uuid);
2745
+ }
2721
2746
  tick(_deltaTime) {
2722
2747
  if (!this.isTickEnabled) {
2723
2748
  return;
@@ -2726,13 +2751,14 @@ class LevelActor extends Actor {
2726
2751
  }
2727
2752
  destroy() {
2728
2753
  this.clearLevel();
2754
+ super.destroy();
2729
2755
  }
2730
2756
  clearLevel() {
2731
2757
  this.childActors.forEach((elem) => {
2732
2758
  elem.destroy();
2733
2759
  });
2734
2760
  this.scene.traverse((child) => {
2735
- if (child instanceof three.Mesh) {
2761
+ if (child instanceof webgpu.Mesh) {
2736
2762
  ThreeObjectLibrary.disposeMeshResource(child);
2737
2763
  }
2738
2764
  });
@@ -2862,9 +2888,9 @@ class LightComponent extends SceneComponent {
2862
2888
  set intensity(intensity) {
2863
2889
  this.threeObject.intensity = intensity;
2864
2890
  }
2865
- constructor(app, light) {
2866
- super(app, light);
2867
- this.obj = light;
2891
+ constructor(app, uuid) {
2892
+ super(app, uuid);
2893
+ this.obj = null;
2868
2894
  }
2869
2895
  }
2870
2896
 
@@ -2887,11 +2913,14 @@ class DirectionalLightComponent extends LightComponent {
2887
2913
  set castShadow(value) {
2888
2914
  this.threeObject.castShadow = value;
2889
2915
  }
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;
2916
+ constructor(app, color = 0xffffff, intensity = 10, uuid) {
2917
+ super(app, uuid);
2918
+ this.obj = null;
2919
+ this.threeObject.color.set(color);
2920
+ this.threeObject.intensity = intensity;
2921
+ }
2922
+ createDefaultObject() {
2923
+ return new webgpu.DirectionalLight(0xffffff, 10);
2895
2924
  }
2896
2925
  setPosition(...args) {
2897
2926
  if (args.length === 1) {
@@ -2918,34 +2947,34 @@ class DirectionalLightComponent extends LightComponent {
2918
2947
  }
2919
2948
 
2920
2949
  class DirectionalLightActor extends Actor {
2921
- constructor(app, color = 0xffffff, intensity = 1) {
2922
- super(app);
2950
+ constructor(app, color = 0xffffff, intensity = 1, uuid) {
2951
+ super(app, uuid);
2923
2952
  this.lightComponent = null;
2924
2953
  this.lightComponent = this.rootComponent;
2925
2954
  if (this.lightComponent) {
2926
2955
  this.lightComponent.color = color;
2927
2956
  this.lightComponent.intensity = intensity;
2957
+ this.lightComponent.castShadow = true;
2928
2958
  }
2929
2959
  this.lightComponent.castShadow = true;
2930
2960
  }
2931
2961
  constructRootComponent() {
2932
- this.lightComponent = new DirectionalLightComponent(this.app);
2933
- this.rootComponent = this.lightComponent;
2934
- this.lightComponent.castShadow = true;
2935
- this.rootComponent.parentActor = this;
2962
+ return new DirectionalLightComponent(this.app);
2936
2963
  }
2937
2964
  }
2938
2965
 
2939
2966
  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);
2967
+ constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial(), uuid) {
2968
+ super(app, new webgpu.BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
2942
2969
  }
2943
2970
  }
2944
2971
 
2945
2972
  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));
2973
+ constructor(app, uuid) {
2974
+ super(app, uuid);
2975
+ }
2976
+ constructRootComponent() {
2977
+ return new BoxComponent(this.app, 1, 1, 1, 1, 1, 1, new webgpu.MeshBasicMaterial(), this.uuid);
2949
2978
  }
2950
2979
  }
2951
2980
 
@@ -2970,18 +2999,19 @@ class SkyComponent extends SceneComponent {
2970
2999
  this.obj.userData["LYObject"] = this;
2971
3000
  }
2972
3001
  }
2973
- constructor(app, skyparam) {
2974
- let obj = new SkyMesh_js.SkyMesh();
2975
- super(app, obj);
3002
+ constructor(app, skyparam, uuid) {
3003
+ super(app, uuid);
3004
+ this.obj = null;
2976
3005
  this.skyParam = DefaultSkyParam;
2977
3006
  this.sunPosition = new webgpu.Vector3();
2978
- this.obj = obj;
2979
- this.name = "SkyComponent";
2980
3007
  if (skyparam) {
2981
3008
  this.skyParam = skyparam;
2982
3009
  }
2983
3010
  this.updateSky();
2984
3011
  }
3012
+ createDefaultObject() {
3013
+ return new SkyMesh_js.SkyMesh();
3014
+ }
2985
3015
  updateSky() {
2986
3016
  var _a, _b;
2987
3017
  this.threeObject.turbidity.value = this.skyParam.turbidity;
@@ -2995,7 +3025,9 @@ class SkyComponent extends SceneComponent {
2995
3025
  (_b = (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport) === null || _b === void 0 ? void 0 : _b.markRenderStateDirty();
2996
3026
  }
2997
3027
  destroyObject() {
2998
- ThreeObjectLibrary.disposeMeshResource(this.obj);
3028
+ if (this.obj) {
3029
+ ThreeObjectLibrary.disposeMeshResource(this.obj);
3030
+ }
2999
3031
  }
3000
3032
  }
3001
3033
 
@@ -3010,40 +3042,31 @@ class SkyActor extends Actor {
3010
3042
  this.setScale(45000, 45000, 45000);
3011
3043
  }
3012
3044
  constructRootComponent() {
3013
- this.skyComponent = new SkyComponent(this.app);
3014
- this.rootComponent = this.skyComponent;
3015
- this.rootComponent.parentActor = this;
3045
+ return new SkyComponent(this.app);
3016
3046
  }
3017
3047
  }
3018
3048
 
3019
3049
  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);
3050
+ constructor(app, width, height, material, widthSegments = 1, heightSegments = 1, uuid) {
3051
+ super(app, new webgpu.PlaneGeometry(width, height, widthSegments, heightSegments), material, uuid);
3022
3052
  }
3023
3053
  }
3024
3054
 
3025
3055
  class PlaneActor extends Actor {
3026
- get planeComponent() {
3027
- return this._planeComponent;
3056
+ constructor(app, uuid) {
3057
+ super(app, uuid);
3028
3058
  }
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;
3059
+ constructRootComponent() {
3060
+ return new PlaneComponent(this.app, 1, 1, new webgpu.MeshBasicMaterial(), 1, 1, this.uuid);
3035
3061
  }
3036
3062
  destroy() {
3037
- var _a;
3038
- (_a = this._planeComponent) === null || _a === void 0 ? void 0 : _a.destroy();
3039
- this._planeComponent = null;
3040
3063
  super.destroy();
3041
3064
  }
3042
3065
  }
3043
3066
 
3044
3067
  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);
3068
+ constructor(app, radius, material = new webgpu.MeshBasicMaterial(), widthSegments = 32, heightSegments = 16, uuid) {
3069
+ super(app, new webgpu.SphereGeometry(radius, widthSegments, heightSegments), material, uuid);
3047
3070
  }
3048
3071
  }
3049
3072
 
@@ -3057,11 +3080,10 @@ class LabelComponent extends SceneComponent {
3057
3080
  this.obj.userData["LYObject"] = this;
3058
3081
  }
3059
3082
  }
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;
3083
+ constructor(app, domElement, center = new webgpu.Vector2(0.5, 1), uuid) {
3084
+ super(app, uuid);
3085
+ this.obj = new CSS2DRenderer_js.CSS2DObject(domElement);
3086
+ this.obj.center.copy(center);
3065
3087
  }
3066
3088
  set isHoverEnabled(bCanHorver) {
3067
3089
  return;
@@ -3128,7 +3150,7 @@ const DefaultSSRParam = {
3128
3150
  class FirstPerson extends Pawn {
3129
3151
  constructor(controller) {
3130
3152
  super(controller);
3131
- this._control = new PointerLockControls.PointerLockControls(controller.camera, controller.viewPort.canvas);
3153
+ this._control = new PointerLockControls_js.PointerLockControls(controller.camera, controller.viewPort.canvas);
3132
3154
  }
3133
3155
  }
3134
3156
 
@@ -3331,6 +3353,7 @@ exports.FirstPerson = FirstPerson;
3331
3353
  exports.GeometryAssetPointer = GeometryAssetPointer;
3332
3354
  exports.LabelComponent = LabelComponent;
3333
3355
  exports.LevelActor = LevelActor;
3356
+ exports.LevelComponent = LevelComponent;
3334
3357
  exports.MaterialAssetPointer = MaterialAssetPointer;
3335
3358
  exports.MeshComponent = MeshComponent;
3336
3359
  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, 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, velocity, metalness, transformedNormalView, blendColor, time, oscSine } from 'three/tsl';
4
4
  import { bloom } from 'three/examples/jsm/tsl/display/BloomNode.js';
@@ -12,10 +12,10 @@ 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
- import { PointerLockControls } from 'three/examples/jsm/controls/PointerLockControls';
18
+ import { PointerLockControls } from 'three/examples/jsm/controls/PointerLockControls.js';
19
19
  import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
20
20
 
21
21
  /*
@@ -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)
@@ -918,7 +927,8 @@ class MaterialAssetPointer extends TAssetPointer {
918
927
  }
919
928
  try {
920
929
  this.textures.set(name, texturePtr);
921
- this.getValue()[name] = texture;
930
+ const matAny = mat;
931
+ matAny[name] = texture;
922
932
  texturePtr.addRef();
923
933
  mat.needsUpdate = true;
924
934
  }
@@ -1148,8 +1158,9 @@ class AssetManager {
1148
1158
  if (!pointer) {
1149
1159
  let textureMap = new Map();
1150
1160
  for (let k in asset) {
1151
- if (asset[k] instanceof Texture) {
1152
- let ptr = this.addTextureAsset(asset[k], 1);
1161
+ const value = asset[k];
1162
+ if (value instanceof Texture) {
1163
+ let ptr = this.addTextureAsset(value, 1);
1153
1164
  textureMap.set(k, ptr);
1154
1165
  }
1155
1166
  }
@@ -1729,7 +1740,6 @@ class Viewport {
1729
1740
  this.smaaPass = null;
1730
1741
  }
1731
1742
  }
1732
- console.log(this.postProcessParam, "sssssssssssssssssssss");
1733
1743
  this.postProcessing.outputNode = finalNode;
1734
1744
  this.markRenderStateDirty();
1735
1745
  }
@@ -2358,8 +2368,8 @@ class Actor extends BaseObject {
2358
2368
  this.app.world.removeTickableActor(this);
2359
2369
  }
2360
2370
  }
2361
- constructor(app, myThreeObject = null) {
2362
- super();
2371
+ constructor(app, uuid) {
2372
+ super(uuid);
2363
2373
  this._name = "Actor";
2364
2374
  this._rootComponent = null;
2365
2375
  this._world = null;
@@ -2368,19 +2378,11 @@ class Actor extends BaseObject {
2368
2378
  this.onHoverBeginEvent = [];
2369
2379
  this.onHoverEndEvent = [];
2370
2380
  this.app = app;
2371
- this.constructRootComponent(myThreeObject);
2381
+ this.rootComponent = this.constructRootComponent();
2382
+ this.rootComponent.parentActor = this;
2372
2383
  }
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
- }
2384
+ constructRootComponent() {
2385
+ return new SceneComponent(this.app);
2384
2386
  }
2385
2387
  getBoundsCenterPosition(bInWorldSpace = true) {
2386
2388
  let ret = new Vector3();
@@ -2702,6 +2704,27 @@ class ThreeObjectLibrary {
2702
2704
  }
2703
2705
  }
2704
2706
 
2707
+ class LevelComponent extends SceneComponent {
2708
+ get threeObject() {
2709
+ if (!this.obj) {
2710
+ throw Error("three object is invalid");
2711
+ }
2712
+ return this.obj;
2713
+ }
2714
+ set threeObject(newThreeObject) {
2715
+ this.obj = newThreeObject;
2716
+ if (this.obj) {
2717
+ this.obj.userData["LYObject"] = this;
2718
+ }
2719
+ }
2720
+ constructor(app, uuid) {
2721
+ super(app, uuid);
2722
+ }
2723
+ createDefaultObject() {
2724
+ return new Scene();
2725
+ }
2726
+ }
2727
+
2705
2728
  class LevelActor extends Actor {
2706
2729
  get scene() {
2707
2730
  if (!this._scene) {
@@ -2709,13 +2732,15 @@ class LevelActor extends Actor {
2709
2732
  }
2710
2733
  return this._scene;
2711
2734
  }
2712
- constructor(app) {
2713
- let scene = new Scene();
2714
- super(app, scene);
2735
+ constructor(app, uuid) {
2736
+ super(app, uuid);
2715
2737
  this._scene = null;
2716
- this._scene = scene;
2738
+ this._scene = this.rootComponent.threeObject;
2717
2739
  this.isTickEnabled = false;
2718
2740
  }
2741
+ constructRootComponent() {
2742
+ return new LevelComponent(this.app, this.uuid);
2743
+ }
2719
2744
  tick(_deltaTime) {
2720
2745
  if (!this.isTickEnabled) {
2721
2746
  return;
@@ -2724,13 +2749,14 @@ class LevelActor extends Actor {
2724
2749
  }
2725
2750
  destroy() {
2726
2751
  this.clearLevel();
2752
+ super.destroy();
2727
2753
  }
2728
2754
  clearLevel() {
2729
2755
  this.childActors.forEach((elem) => {
2730
2756
  elem.destroy();
2731
2757
  });
2732
2758
  this.scene.traverse((child) => {
2733
- if (child instanceof Mesh$1) {
2759
+ if (child instanceof Mesh) {
2734
2760
  ThreeObjectLibrary.disposeMeshResource(child);
2735
2761
  }
2736
2762
  });
@@ -2860,9 +2886,9 @@ class LightComponent extends SceneComponent {
2860
2886
  set intensity(intensity) {
2861
2887
  this.threeObject.intensity = intensity;
2862
2888
  }
2863
- constructor(app, light) {
2864
- super(app, light);
2865
- this.obj = light;
2889
+ constructor(app, uuid) {
2890
+ super(app, uuid);
2891
+ this.obj = null;
2866
2892
  }
2867
2893
  }
2868
2894
 
@@ -2885,11 +2911,14 @@ class DirectionalLightComponent extends LightComponent {
2885
2911
  set castShadow(value) {
2886
2912
  this.threeObject.castShadow = value;
2887
2913
  }
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;
2914
+ constructor(app, color = 0xffffff, intensity = 10, uuid) {
2915
+ super(app, uuid);
2916
+ this.obj = null;
2917
+ this.threeObject.color.set(color);
2918
+ this.threeObject.intensity = intensity;
2919
+ }
2920
+ createDefaultObject() {
2921
+ return new DirectionalLight(0xffffff, 10);
2893
2922
  }
2894
2923
  setPosition(...args) {
2895
2924
  if (args.length === 1) {
@@ -2916,34 +2945,34 @@ class DirectionalLightComponent extends LightComponent {
2916
2945
  }
2917
2946
 
2918
2947
  class DirectionalLightActor extends Actor {
2919
- constructor(app, color = 0xffffff, intensity = 1) {
2920
- super(app);
2948
+ constructor(app, color = 0xffffff, intensity = 1, uuid) {
2949
+ super(app, uuid);
2921
2950
  this.lightComponent = null;
2922
2951
  this.lightComponent = this.rootComponent;
2923
2952
  if (this.lightComponent) {
2924
2953
  this.lightComponent.color = color;
2925
2954
  this.lightComponent.intensity = intensity;
2955
+ this.lightComponent.castShadow = true;
2926
2956
  }
2927
2957
  this.lightComponent.castShadow = true;
2928
2958
  }
2929
2959
  constructRootComponent() {
2930
- this.lightComponent = new DirectionalLightComponent(this.app);
2931
- this.rootComponent = this.lightComponent;
2932
- this.lightComponent.castShadow = true;
2933
- this.rootComponent.parentActor = this;
2960
+ return new DirectionalLightComponent(this.app);
2934
2961
  }
2935
2962
  }
2936
2963
 
2937
2964
  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);
2965
+ constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshStandardMaterial(), uuid) {
2966
+ super(app, new BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments), material, uuid);
2940
2967
  }
2941
2968
  }
2942
2969
 
2943
2970
  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));
2971
+ constructor(app, uuid) {
2972
+ super(app, uuid);
2973
+ }
2974
+ constructRootComponent() {
2975
+ return new BoxComponent(this.app, 1, 1, 1, 1, 1, 1, new MeshBasicMaterial(), this.uuid);
2947
2976
  }
2948
2977
  }
2949
2978
 
@@ -2968,18 +2997,19 @@ class SkyComponent extends SceneComponent {
2968
2997
  this.obj.userData["LYObject"] = this;
2969
2998
  }
2970
2999
  }
2971
- constructor(app, skyparam) {
2972
- let obj = new SkyMesh();
2973
- super(app, obj);
3000
+ constructor(app, skyparam, uuid) {
3001
+ super(app, uuid);
3002
+ this.obj = null;
2974
3003
  this.skyParam = DefaultSkyParam;
2975
3004
  this.sunPosition = new Vector3();
2976
- this.obj = obj;
2977
- this.name = "SkyComponent";
2978
3005
  if (skyparam) {
2979
3006
  this.skyParam = skyparam;
2980
3007
  }
2981
3008
  this.updateSky();
2982
3009
  }
3010
+ createDefaultObject() {
3011
+ return new SkyMesh();
3012
+ }
2983
3013
  updateSky() {
2984
3014
  var _a, _b;
2985
3015
  this.threeObject.turbidity.value = this.skyParam.turbidity;
@@ -2993,7 +3023,9 @@ class SkyComponent extends SceneComponent {
2993
3023
  (_b = (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport) === null || _b === void 0 ? void 0 : _b.markRenderStateDirty();
2994
3024
  }
2995
3025
  destroyObject() {
2996
- ThreeObjectLibrary.disposeMeshResource(this.obj);
3026
+ if (this.obj) {
3027
+ ThreeObjectLibrary.disposeMeshResource(this.obj);
3028
+ }
2997
3029
  }
2998
3030
  }
2999
3031
 
@@ -3008,40 +3040,31 @@ class SkyActor extends Actor {
3008
3040
  this.setScale(45000, 45000, 45000);
3009
3041
  }
3010
3042
  constructRootComponent() {
3011
- this.skyComponent = new SkyComponent(this.app);
3012
- this.rootComponent = this.skyComponent;
3013
- this.rootComponent.parentActor = this;
3043
+ return new SkyComponent(this.app);
3014
3044
  }
3015
3045
  }
3016
3046
 
3017
3047
  class PlaneComponent extends MeshComponent {
3018
- constructor(app, width, height, material, widthSegments = 1, heightSegments = 1) {
3019
- super(app, new PlaneGeometry(width, height, widthSegments, heightSegments), material);
3048
+ constructor(app, width, height, material, widthSegments = 1, heightSegments = 1, uuid) {
3049
+ super(app, new PlaneGeometry(width, height, widthSegments, heightSegments), material, uuid);
3020
3050
  }
3021
3051
  }
3022
3052
 
3023
3053
  class PlaneActor extends Actor {
3024
- get planeComponent() {
3025
- return this._planeComponent;
3054
+ constructor(app, uuid) {
3055
+ super(app, uuid);
3026
3056
  }
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;
3057
+ constructRootComponent() {
3058
+ return new PlaneComponent(this.app, 1, 1, new MeshBasicMaterial(), 1, 1, this.uuid);
3033
3059
  }
3034
3060
  destroy() {
3035
- var _a;
3036
- (_a = this._planeComponent) === null || _a === void 0 ? void 0 : _a.destroy();
3037
- this._planeComponent = null;
3038
3061
  super.destroy();
3039
3062
  }
3040
3063
  }
3041
3064
 
3042
3065
  class SphereComponent extends MeshComponent {
3043
- constructor(app, radius, material = new MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
3044
- super(app, new SphereGeometry(radius, widthSegments, heightSegments), material);
3066
+ constructor(app, radius, material = new MeshBasicMaterial(), widthSegments = 32, heightSegments = 16, uuid) {
3067
+ super(app, new SphereGeometry(radius, widthSegments, heightSegments), material, uuid);
3045
3068
  }
3046
3069
  }
3047
3070
 
@@ -3055,11 +3078,10 @@ class LabelComponent extends SceneComponent {
3055
3078
  this.obj.userData["LYObject"] = this;
3056
3079
  }
3057
3080
  }
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;
3081
+ constructor(app, domElement, center = new Vector2(0.5, 1), uuid) {
3082
+ super(app, uuid);
3083
+ this.obj = new CSS2DObject(domElement);
3084
+ this.obj.center.copy(center);
3063
3085
  }
3064
3086
  set isHoverEnabled(bCanHorver) {
3065
3087
  return;
@@ -3303,4 +3325,4 @@ class TransformGizmo extends Pawn {
3303
3325
  }
3304
3326
  }
3305
3327
 
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 };
3328
+ 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,3 @@
1
- import { WebGPURendererParameters } from "three/src/renderers/webgpu/WebGPURenderer";
2
1
  import { CameraParam } from "./CameraParameter";
3
2
  import { WorldParam } from "./WorldParameter";
4
3
  import { Controller } from "../Controller";
@@ -7,6 +6,7 @@ import { Viewport } from "../Viewport";
7
6
  import { ViewportParam } from "./ViewportParameters";
8
7
  import { AssetManager } from "../../AssetManagement/AssetManager";
9
8
  import { PostProcessParam } from "../../PostProcess/PostProcessParam";
9
+ import { WebGPURendererParameters } from "three/src/renderers/webgpu/WebGPURenderer.js";
10
10
  export interface AppClass {
11
11
  assetManagerClass: typeof AssetManager;
12
12
  controllerClass: typeof Controller;
@@ -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,7 @@
1
- import { Material } from "three/webgpu";
2
1
  import { Actor } from "../../Actor";
2
+ import { BoxComponent } from "../../Components/Mesh/Shape/BoxComponent";
3
3
  import { ThreeJsApp } from "../../../ThreeJsApp";
4
4
  export declare class BoxActor extends Actor {
5
- constructor(app: ThreeJsApp, width?: number, height?: number, depth?: number, widthSegments?: number, heightSegments?: number, depthSegments?: number, material?: Material);
5
+ constructor(app: ThreeJsApp, uuid?: string);
6
+ protected constructRootComponent(): BoxComponent;
6
7
  }
@@ -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
  }
@@ -4,6 +4,6 @@ import { ThreeJsApp } from "../../../../ThreeJsApp";
4
4
  export declare class SpriteComponent extends SceneComponent {
5
5
  get threeObject(): Sprite;
6
6
  set threeObject(newThreeObject: Sprite);
7
- protected obj: Sprite;
8
- constructor(app: ThreeJsApp, texture: Texture);
7
+ constructor(app: ThreeJsApp, texture: Texture, uuid?: string);
8
+ protected createDefaultObject(): Sprite;
9
9
  }
@@ -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.1",
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
+ }