lythreeframe 1.1.18 → 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.
- package/dist/bundle.cjs.js +109 -81
- package/dist/bundle.esm.js +111 -84
- package/dist/index.d.ts +1 -0
- package/dist/lythreeframe/AssetManagement/AssetManager.d.ts +1 -1
- package/dist/lythreeframe/Factory/CameraFactory.d.ts +1 -1
- package/dist/lythreeframe/Library/Math.d.ts +5 -5
- package/dist/lythreeframe/Object/Actor.d.ts +7 -7
- package/dist/lythreeframe/Object/Actors/Level/LevelActor.d.ts +4 -1
- package/dist/lythreeframe/Object/Actors/Light/DirectionalLightActor.d.ts +2 -2
- package/dist/lythreeframe/Object/Actors/Shape/BoxActor.d.ts +2 -2
- package/dist/lythreeframe/Object/Actors/Shape/PlaneActor.d.ts +2 -4
- package/dist/lythreeframe/Object/Actors/Sky/SkyActor.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/2D/2DComponent.d.ts +2 -1
- package/dist/lythreeframe/Object/Components/Component.d.ts +2 -1
- package/dist/lythreeframe/Object/Components/Level/LevelComponent.d.ts +9 -0
- package/dist/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.d.ts +2 -1
- package/dist/lythreeframe/Object/Components/Light/LightComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Mesh/MeshComponent.d.ts +3 -2
- package/dist/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.d.ts +1 -1
- package/dist/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.d.ts +2 -1
- package/dist/lythreeframe/Object/Components/SceneComponent.d.ts +14 -14
- package/dist/lythreeframe/Object/Components/Sky/SkyComponent.d.ts +2 -1
- package/dist/lythreeframe/Object/PawnV2/Oribital.d.ts +1 -1
- package/dist/lythreeframe/Object/PawnV2/Pawn.d.ts +1 -1
- package/dist/lythreeframe/PostProcess/Param/ToneMapping.d.ts +1 -1
- package/package.json +39 -39
package/dist/bundle.cjs.js
CHANGED
|
@@ -85,14 +85,17 @@ class Component extends BaseObject {
|
|
|
85
85
|
set name(name) {
|
|
86
86
|
this._name = name;
|
|
87
87
|
}
|
|
88
|
-
constructor(
|
|
89
|
-
super(
|
|
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 =
|
|
95
|
-
this._name = `${
|
|
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,
|
|
132
|
-
super(
|
|
134
|
+
constructor(app, uuid) {
|
|
135
|
+
super(uuid);
|
|
133
136
|
this.bCanHover = false;
|
|
134
137
|
this.bCanClick = false;
|
|
135
138
|
this.app = app;
|
|
136
|
-
this.
|
|
139
|
+
this.name = "SceneComponent";
|
|
137
140
|
}
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
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 =
|
|
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,
|
|
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(
|
|
2382
|
+
this.rootComponent = this.constructRootComponent();
|
|
2383
|
+
this.rootComponent.parentActor = this;
|
|
2374
2384
|
}
|
|
2375
|
-
constructRootComponent(
|
|
2376
|
-
|
|
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,22 +2733,31 @@ class LevelActor extends Actor {
|
|
|
2711
2733
|
}
|
|
2712
2734
|
return this._scene;
|
|
2713
2735
|
}
|
|
2714
|
-
constructor(app) {
|
|
2715
|
-
|
|
2716
|
-
super(app, scene);
|
|
2736
|
+
constructor(app, uuid) {
|
|
2737
|
+
super(app, uuid);
|
|
2717
2738
|
this._scene = null;
|
|
2718
|
-
this._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) {
|
|
2747
|
+
return;
|
|
2748
|
+
}
|
|
2749
|
+
super.tick(_deltaTime);
|
|
2723
2750
|
}
|
|
2724
2751
|
destroy() {
|
|
2752
|
+
this.clearLevel();
|
|
2753
|
+
super.destroy();
|
|
2754
|
+
}
|
|
2755
|
+
clearLevel() {
|
|
2725
2756
|
this.childActors.forEach((elem) => {
|
|
2726
2757
|
elem.destroy();
|
|
2727
2758
|
});
|
|
2728
2759
|
this.scene.traverse((child) => {
|
|
2729
|
-
if (child instanceof
|
|
2760
|
+
if (child instanceof webgpu.Mesh) {
|
|
2730
2761
|
ThreeObjectLibrary.disposeMeshResource(child);
|
|
2731
2762
|
}
|
|
2732
2763
|
});
|
|
@@ -2856,9 +2887,9 @@ class LightComponent extends SceneComponent {
|
|
|
2856
2887
|
set intensity(intensity) {
|
|
2857
2888
|
this.threeObject.intensity = intensity;
|
|
2858
2889
|
}
|
|
2859
|
-
constructor(app,
|
|
2860
|
-
super(app,
|
|
2861
|
-
this.obj =
|
|
2890
|
+
constructor(app, uuid) {
|
|
2891
|
+
super(app, uuid);
|
|
2892
|
+
this.obj = null;
|
|
2862
2893
|
}
|
|
2863
2894
|
}
|
|
2864
2895
|
|
|
@@ -2881,11 +2912,14 @@ class DirectionalLightComponent extends LightComponent {
|
|
|
2881
2912
|
set castShadow(value) {
|
|
2882
2913
|
this.threeObject.castShadow = value;
|
|
2883
2914
|
}
|
|
2884
|
-
constructor(app, color = 0xffffff, intensity = 10) {
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
this.
|
|
2888
|
-
|
|
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);
|
|
2889
2923
|
}
|
|
2890
2924
|
setPosition(...args) {
|
|
2891
2925
|
if (args.length === 1) {
|
|
@@ -2912,34 +2946,34 @@ class DirectionalLightComponent extends LightComponent {
|
|
|
2912
2946
|
}
|
|
2913
2947
|
|
|
2914
2948
|
class DirectionalLightActor extends Actor {
|
|
2915
|
-
constructor(app, color = 0xffffff, intensity = 1) {
|
|
2916
|
-
super(app);
|
|
2949
|
+
constructor(app, color = 0xffffff, intensity = 1, uuid) {
|
|
2950
|
+
super(app, uuid);
|
|
2917
2951
|
this.lightComponent = null;
|
|
2918
2952
|
this.lightComponent = this.rootComponent;
|
|
2919
2953
|
if (this.lightComponent) {
|
|
2920
2954
|
this.lightComponent.color = color;
|
|
2921
2955
|
this.lightComponent.intensity = intensity;
|
|
2956
|
+
this.lightComponent.castShadow = true;
|
|
2922
2957
|
}
|
|
2923
2958
|
this.lightComponent.castShadow = true;
|
|
2924
2959
|
}
|
|
2925
2960
|
constructRootComponent() {
|
|
2926
|
-
|
|
2927
|
-
this.rootComponent = this.lightComponent;
|
|
2928
|
-
this.lightComponent.castShadow = true;
|
|
2929
|
-
this.rootComponent.parentActor = this;
|
|
2961
|
+
return new DirectionalLightComponent(this.app);
|
|
2930
2962
|
}
|
|
2931
2963
|
}
|
|
2932
2964
|
|
|
2933
2965
|
class BoxComponent extends MeshComponent {
|
|
2934
|
-
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new webgpu.MeshStandardMaterial()) {
|
|
2935
|
-
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);
|
|
2936
2968
|
}
|
|
2937
2969
|
}
|
|
2938
2970
|
|
|
2939
2971
|
class BoxActor extends Actor {
|
|
2940
|
-
constructor(app,
|
|
2941
|
-
super(app);
|
|
2942
|
-
|
|
2972
|
+
constructor(app, uuid) {
|
|
2973
|
+
super(app, uuid);
|
|
2974
|
+
}
|
|
2975
|
+
constructRootComponent() {
|
|
2976
|
+
this.rootComponent = new BoxComponent(this.app);
|
|
2943
2977
|
}
|
|
2944
2978
|
}
|
|
2945
2979
|
|
|
@@ -2964,18 +2998,19 @@ class SkyComponent extends SceneComponent {
|
|
|
2964
2998
|
this.obj.userData["LYObject"] = this;
|
|
2965
2999
|
}
|
|
2966
3000
|
}
|
|
2967
|
-
constructor(app, skyparam) {
|
|
2968
|
-
|
|
2969
|
-
|
|
3001
|
+
constructor(app, skyparam, uuid) {
|
|
3002
|
+
super(app, uuid);
|
|
3003
|
+
this.obj = null;
|
|
2970
3004
|
this.skyParam = DefaultSkyParam;
|
|
2971
3005
|
this.sunPosition = new webgpu.Vector3();
|
|
2972
|
-
this.obj = obj;
|
|
2973
|
-
this.name = "SkyComponent";
|
|
2974
3006
|
if (skyparam) {
|
|
2975
3007
|
this.skyParam = skyparam;
|
|
2976
3008
|
}
|
|
2977
3009
|
this.updateSky();
|
|
2978
3010
|
}
|
|
3011
|
+
createDefaultObject() {
|
|
3012
|
+
return new SkyMesh_js.SkyMesh();
|
|
3013
|
+
}
|
|
2979
3014
|
updateSky() {
|
|
2980
3015
|
var _a, _b;
|
|
2981
3016
|
this.threeObject.turbidity.value = this.skyParam.turbidity;
|
|
@@ -2989,7 +3024,9 @@ class SkyComponent extends SceneComponent {
|
|
|
2989
3024
|
(_b = (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport) === null || _b === void 0 ? void 0 : _b.markRenderStateDirty();
|
|
2990
3025
|
}
|
|
2991
3026
|
destroyObject() {
|
|
2992
|
-
|
|
3027
|
+
if (this.obj) {
|
|
3028
|
+
ThreeObjectLibrary.disposeMeshResource(this.obj);
|
|
3029
|
+
}
|
|
2993
3030
|
}
|
|
2994
3031
|
}
|
|
2995
3032
|
|
|
@@ -3004,40 +3041,31 @@ class SkyActor extends Actor {
|
|
|
3004
3041
|
this.setScale(45000, 45000, 45000);
|
|
3005
3042
|
}
|
|
3006
3043
|
constructRootComponent() {
|
|
3007
|
-
|
|
3008
|
-
this.rootComponent = this.skyComponent;
|
|
3009
|
-
this.rootComponent.parentActor = this;
|
|
3044
|
+
return new SkyComponent(this.app);
|
|
3010
3045
|
}
|
|
3011
3046
|
}
|
|
3012
3047
|
|
|
3013
3048
|
class PlaneComponent extends MeshComponent {
|
|
3014
|
-
constructor(app, width, height, material, widthSegments = 1, heightSegments = 1) {
|
|
3015
|
-
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);
|
|
3016
3051
|
}
|
|
3017
3052
|
}
|
|
3018
3053
|
|
|
3019
3054
|
class PlaneActor extends Actor {
|
|
3020
|
-
|
|
3021
|
-
|
|
3055
|
+
constructor(app, uuid) {
|
|
3056
|
+
super(app, uuid);
|
|
3022
3057
|
}
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
this._planeComponent = new PlaneComponent(this.app, width, height, material, widthSegments, heightSegments);
|
|
3026
|
-
this._planeComponent.setRotation(Math.PI * 0.5 * -1, 0, 0);
|
|
3027
|
-
this.addComponent(this._planeComponent);
|
|
3028
|
-
this._planeComponent.receiveShadow = true;
|
|
3058
|
+
constructRootComponent() {
|
|
3059
|
+
return new PlaneComponent(this.app, 1, 1, new webgpu.MeshBasicMaterial(), 1, 1, this.uuid);
|
|
3029
3060
|
}
|
|
3030
3061
|
destroy() {
|
|
3031
|
-
var _a;
|
|
3032
|
-
(_a = this._planeComponent) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
3033
|
-
this._planeComponent = null;
|
|
3034
3062
|
super.destroy();
|
|
3035
3063
|
}
|
|
3036
3064
|
}
|
|
3037
3065
|
|
|
3038
3066
|
class SphereComponent extends MeshComponent {
|
|
3039
|
-
constructor(app, radius, material = new webgpu.MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
|
|
3040
|
-
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);
|
|
3041
3069
|
}
|
|
3042
3070
|
}
|
|
3043
3071
|
|
|
@@ -3051,11 +3079,10 @@ class LabelComponent extends SceneComponent {
|
|
|
3051
3079
|
this.obj.userData["LYObject"] = this;
|
|
3052
3080
|
}
|
|
3053
3081
|
}
|
|
3054
|
-
constructor(app, domElement, center = new webgpu.Vector2(0.5, 1)) {
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
this.obj
|
|
3058
|
-
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);
|
|
3059
3086
|
}
|
|
3060
3087
|
set isHoverEnabled(bCanHorver) {
|
|
3061
3088
|
return;
|
|
@@ -3325,6 +3352,7 @@ exports.FirstPerson = FirstPerson;
|
|
|
3325
3352
|
exports.GeometryAssetPointer = GeometryAssetPointer;
|
|
3326
3353
|
exports.LabelComponent = LabelComponent;
|
|
3327
3354
|
exports.LevelActor = LevelActor;
|
|
3355
|
+
exports.LevelComponent = LevelComponent;
|
|
3328
3356
|
exports.MaterialAssetPointer = MaterialAssetPointer;
|
|
3329
3357
|
exports.MeshComponent = MeshComponent;
|
|
3330
3358
|
exports.Orbital = Orbital;
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MathUtils,
|
|
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 {
|
|
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(
|
|
87
|
-
super(
|
|
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 =
|
|
93
|
-
this._name = `${
|
|
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,
|
|
130
|
-
super(
|
|
132
|
+
constructor(app, uuid) {
|
|
133
|
+
super(uuid);
|
|
131
134
|
this.bCanHover = false;
|
|
132
135
|
this.bCanClick = false;
|
|
133
136
|
this.app = app;
|
|
134
|
-
this.
|
|
137
|
+
this.name = "SceneComponent";
|
|
135
138
|
}
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
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 =
|
|
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,
|
|
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(
|
|
2380
|
+
this.rootComponent = this.constructRootComponent();
|
|
2381
|
+
this.rootComponent.parentActor = this;
|
|
2372
2382
|
}
|
|
2373
|
-
constructRootComponent(
|
|
2374
|
-
|
|
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,22 +2731,31 @@ class LevelActor extends Actor {
|
|
|
2709
2731
|
}
|
|
2710
2732
|
return this._scene;
|
|
2711
2733
|
}
|
|
2712
|
-
constructor(app) {
|
|
2713
|
-
|
|
2714
|
-
super(app, scene);
|
|
2734
|
+
constructor(app, uuid) {
|
|
2735
|
+
super(app, uuid);
|
|
2715
2736
|
this._scene = null;
|
|
2716
|
-
this._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) {
|
|
2745
|
+
return;
|
|
2746
|
+
}
|
|
2747
|
+
super.tick(_deltaTime);
|
|
2721
2748
|
}
|
|
2722
2749
|
destroy() {
|
|
2750
|
+
this.clearLevel();
|
|
2751
|
+
super.destroy();
|
|
2752
|
+
}
|
|
2753
|
+
clearLevel() {
|
|
2723
2754
|
this.childActors.forEach((elem) => {
|
|
2724
2755
|
elem.destroy();
|
|
2725
2756
|
});
|
|
2726
2757
|
this.scene.traverse((child) => {
|
|
2727
|
-
if (child instanceof Mesh
|
|
2758
|
+
if (child instanceof Mesh) {
|
|
2728
2759
|
ThreeObjectLibrary.disposeMeshResource(child);
|
|
2729
2760
|
}
|
|
2730
2761
|
});
|
|
@@ -2854,9 +2885,9 @@ class LightComponent extends SceneComponent {
|
|
|
2854
2885
|
set intensity(intensity) {
|
|
2855
2886
|
this.threeObject.intensity = intensity;
|
|
2856
2887
|
}
|
|
2857
|
-
constructor(app,
|
|
2858
|
-
super(app,
|
|
2859
|
-
this.obj =
|
|
2888
|
+
constructor(app, uuid) {
|
|
2889
|
+
super(app, uuid);
|
|
2890
|
+
this.obj = null;
|
|
2860
2891
|
}
|
|
2861
2892
|
}
|
|
2862
2893
|
|
|
@@ -2879,11 +2910,14 @@ class DirectionalLightComponent extends LightComponent {
|
|
|
2879
2910
|
set castShadow(value) {
|
|
2880
2911
|
this.threeObject.castShadow = value;
|
|
2881
2912
|
}
|
|
2882
|
-
constructor(app, color = 0xffffff, intensity = 10) {
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
this.
|
|
2886
|
-
|
|
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);
|
|
2887
2921
|
}
|
|
2888
2922
|
setPosition(...args) {
|
|
2889
2923
|
if (args.length === 1) {
|
|
@@ -2910,34 +2944,34 @@ class DirectionalLightComponent extends LightComponent {
|
|
|
2910
2944
|
}
|
|
2911
2945
|
|
|
2912
2946
|
class DirectionalLightActor extends Actor {
|
|
2913
|
-
constructor(app, color = 0xffffff, intensity = 1) {
|
|
2914
|
-
super(app);
|
|
2947
|
+
constructor(app, color = 0xffffff, intensity = 1, uuid) {
|
|
2948
|
+
super(app, uuid);
|
|
2915
2949
|
this.lightComponent = null;
|
|
2916
2950
|
this.lightComponent = this.rootComponent;
|
|
2917
2951
|
if (this.lightComponent) {
|
|
2918
2952
|
this.lightComponent.color = color;
|
|
2919
2953
|
this.lightComponent.intensity = intensity;
|
|
2954
|
+
this.lightComponent.castShadow = true;
|
|
2920
2955
|
}
|
|
2921
2956
|
this.lightComponent.castShadow = true;
|
|
2922
2957
|
}
|
|
2923
2958
|
constructRootComponent() {
|
|
2924
|
-
|
|
2925
|
-
this.rootComponent = this.lightComponent;
|
|
2926
|
-
this.lightComponent.castShadow = true;
|
|
2927
|
-
this.rootComponent.parentActor = this;
|
|
2959
|
+
return new DirectionalLightComponent(this.app);
|
|
2928
2960
|
}
|
|
2929
2961
|
}
|
|
2930
2962
|
|
|
2931
2963
|
class BoxComponent extends MeshComponent {
|
|
2932
|
-
constructor(app, width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1, material = new MeshStandardMaterial()) {
|
|
2933
|
-
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);
|
|
2934
2966
|
}
|
|
2935
2967
|
}
|
|
2936
2968
|
|
|
2937
2969
|
class BoxActor extends Actor {
|
|
2938
|
-
constructor(app,
|
|
2939
|
-
super(app);
|
|
2940
|
-
|
|
2970
|
+
constructor(app, uuid) {
|
|
2971
|
+
super(app, uuid);
|
|
2972
|
+
}
|
|
2973
|
+
constructRootComponent() {
|
|
2974
|
+
this.rootComponent = new BoxComponent(this.app);
|
|
2941
2975
|
}
|
|
2942
2976
|
}
|
|
2943
2977
|
|
|
@@ -2962,18 +2996,19 @@ class SkyComponent extends SceneComponent {
|
|
|
2962
2996
|
this.obj.userData["LYObject"] = this;
|
|
2963
2997
|
}
|
|
2964
2998
|
}
|
|
2965
|
-
constructor(app, skyparam) {
|
|
2966
|
-
|
|
2967
|
-
|
|
2999
|
+
constructor(app, skyparam, uuid) {
|
|
3000
|
+
super(app, uuid);
|
|
3001
|
+
this.obj = null;
|
|
2968
3002
|
this.skyParam = DefaultSkyParam;
|
|
2969
3003
|
this.sunPosition = new Vector3();
|
|
2970
|
-
this.obj = obj;
|
|
2971
|
-
this.name = "SkyComponent";
|
|
2972
3004
|
if (skyparam) {
|
|
2973
3005
|
this.skyParam = skyparam;
|
|
2974
3006
|
}
|
|
2975
3007
|
this.updateSky();
|
|
2976
3008
|
}
|
|
3009
|
+
createDefaultObject() {
|
|
3010
|
+
return new SkyMesh();
|
|
3011
|
+
}
|
|
2977
3012
|
updateSky() {
|
|
2978
3013
|
var _a, _b;
|
|
2979
3014
|
this.threeObject.turbidity.value = this.skyParam.turbidity;
|
|
@@ -2987,7 +3022,9 @@ class SkyComponent extends SceneComponent {
|
|
|
2987
3022
|
(_b = (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport) === null || _b === void 0 ? void 0 : _b.markRenderStateDirty();
|
|
2988
3023
|
}
|
|
2989
3024
|
destroyObject() {
|
|
2990
|
-
|
|
3025
|
+
if (this.obj) {
|
|
3026
|
+
ThreeObjectLibrary.disposeMeshResource(this.obj);
|
|
3027
|
+
}
|
|
2991
3028
|
}
|
|
2992
3029
|
}
|
|
2993
3030
|
|
|
@@ -3002,40 +3039,31 @@ class SkyActor extends Actor {
|
|
|
3002
3039
|
this.setScale(45000, 45000, 45000);
|
|
3003
3040
|
}
|
|
3004
3041
|
constructRootComponent() {
|
|
3005
|
-
|
|
3006
|
-
this.rootComponent = this.skyComponent;
|
|
3007
|
-
this.rootComponent.parentActor = this;
|
|
3042
|
+
return new SkyComponent(this.app);
|
|
3008
3043
|
}
|
|
3009
3044
|
}
|
|
3010
3045
|
|
|
3011
3046
|
class PlaneComponent extends MeshComponent {
|
|
3012
|
-
constructor(app, width, height, material, widthSegments = 1, heightSegments = 1) {
|
|
3013
|
-
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);
|
|
3014
3049
|
}
|
|
3015
3050
|
}
|
|
3016
3051
|
|
|
3017
3052
|
class PlaneActor extends Actor {
|
|
3018
|
-
|
|
3019
|
-
|
|
3053
|
+
constructor(app, uuid) {
|
|
3054
|
+
super(app, uuid);
|
|
3020
3055
|
}
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
this._planeComponent = new PlaneComponent(this.app, width, height, material, widthSegments, heightSegments);
|
|
3024
|
-
this._planeComponent.setRotation(Math.PI * 0.5 * -1, 0, 0);
|
|
3025
|
-
this.addComponent(this._planeComponent);
|
|
3026
|
-
this._planeComponent.receiveShadow = true;
|
|
3056
|
+
constructRootComponent() {
|
|
3057
|
+
return new PlaneComponent(this.app, 1, 1, new MeshBasicMaterial(), 1, 1, this.uuid);
|
|
3027
3058
|
}
|
|
3028
3059
|
destroy() {
|
|
3029
|
-
var _a;
|
|
3030
|
-
(_a = this._planeComponent) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
3031
|
-
this._planeComponent = null;
|
|
3032
3060
|
super.destroy();
|
|
3033
3061
|
}
|
|
3034
3062
|
}
|
|
3035
3063
|
|
|
3036
3064
|
class SphereComponent extends MeshComponent {
|
|
3037
|
-
constructor(app, radius, material = new MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
|
|
3038
|
-
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);
|
|
3039
3067
|
}
|
|
3040
3068
|
}
|
|
3041
3069
|
|
|
@@ -3049,11 +3077,10 @@ class LabelComponent extends SceneComponent {
|
|
|
3049
3077
|
this.obj.userData["LYObject"] = this;
|
|
3050
3078
|
}
|
|
3051
3079
|
}
|
|
3052
|
-
constructor(app, domElement, center = new Vector2(0.5, 1)) {
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
this.obj
|
|
3056
|
-
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);
|
|
3057
3084
|
}
|
|
3058
3085
|
set isHoverEnabled(bCanHorver) {
|
|
3059
3086
|
return;
|
|
@@ -3297,4 +3324,4 @@ class TransformGizmo extends Pawn {
|
|
|
3297
3324
|
}
|
|
3298
3325
|
}
|
|
3299
3326
|
|
|
3300
|
-
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):
|
|
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):
|
|
15
|
-
static MaxVector(v1: Vector3, v2: Vector3):
|
|
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):
|
|
26
|
-
static intersectRayPlane(rayOrigin: Vector3, rayDirection: Vector3, planeNormal: Vector3, planePoint: Vector3):
|
|
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
|
|
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,
|
|
27
|
-
protected constructRootComponent(
|
|
28
|
-
getBoundsCenterPosition(bInWorldSpace?: boolean):
|
|
29
|
-
getBoundsTopCenterPosition(bInWorldSpace?: boolean):
|
|
30
|
-
getBoundsBottomCenterPosition(bInWorldSpace?: boolean):
|
|
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,13 @@
|
|
|
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;
|
|
12
|
+
clearLevel(): void;
|
|
10
13
|
}
|
|
@@ -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():
|
|
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,
|
|
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
|
-
|
|
7
|
-
|
|
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
|
}
|
|
@@ -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?:
|
|
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(
|
|
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
|
+
}
|
package/dist/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.d.ts
CHANGED
|
@@ -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,
|
|
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
|
|
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?:
|
|
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,
|
|
15
|
-
|
|
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():
|
|
29
|
+
getPosition(): Vector3;
|
|
30
30
|
setPosition(position: Vector3): void;
|
|
31
31
|
setPosition(x: number, y: number, z: number): void;
|
|
32
|
-
getRotation():
|
|
32
|
+
getRotation(): Euler;
|
|
33
33
|
setRotation(rotation: Euler): void;
|
|
34
34
|
setRotation(x: number, y: number, z: number): void;
|
|
35
|
-
getQuaternion():
|
|
35
|
+
getQuaternion(): Quaternion;
|
|
36
36
|
setQuaternion(quat: Quaternion): void;
|
|
37
37
|
setQuaternion(x: number, y: number, z: number, w: number): void;
|
|
38
|
-
getScale():
|
|
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():
|
|
44
|
-
getWorldRotation():
|
|
45
|
-
getWorldQuaternion():
|
|
46
|
-
getWorldScale():
|
|
47
|
-
getWorldMatrix():
|
|
43
|
+
getWorldPosition(): Vector3;
|
|
44
|
+
getWorldRotation(): Euler;
|
|
45
|
+
getWorldQuaternion(): Quaternion;
|
|
46
|
+
getWorldScale(): Vector3;
|
|
47
|
+
getWorldMatrix(): Matrix4;
|
|
48
48
|
setWorldMatrix(newMatrix: Matrix4): void;
|
|
49
|
-
getWorldForwardDirection():
|
|
50
|
-
getWorldUpDirection():
|
|
51
|
-
getWorldRightDirection():
|
|
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():
|
|
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():
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "lythreeframe",
|
|
3
|
-
"version": "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
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist"
|
|
20
|
-
],
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@rollup/plugin-typescript": "^12.1.2",
|
|
23
|
-
"@types/three": "^0.
|
|
24
|
-
"gsap": "^3.12.2",
|
|
25
|
-
"rollup": "^4.35.0",
|
|
26
|
-
"three": "^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
|
+
}
|