lythreeframe 1.0.20 → 1.0.22
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 +40 -12
- package/dist/bundle.esm.js +40 -12
- package/dist/index.d.ts +6 -3
- package/dist/lythreeframe/Factory/CameraFactory.d.ts +1 -15
- package/dist/lythreeframe/Frame/Parameters/AppParameter.d.ts +12 -0
- package/dist/lythreeframe/Frame/Parameters/CameraParameter.d.ts +16 -0
- package/dist/lythreeframe/Frame/Parameters/WorldParameter.d.ts +2 -0
- package/dist/lythreeframe/Frame/World.d.ts +1 -1
- package/dist/lythreeframe/Library/ResourceLibrary.d.ts +1 -1
- package/dist/lythreeframe/ThreeJsApp.d.ts +3 -12
- package/package.json +1 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -1080,6 +1080,22 @@ const DefaultPostProcessParam = {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
};
|
|
1082
1082
|
|
|
1083
|
+
class ThreeObjectLibrary {
|
|
1084
|
+
static disposeMeshMaterial(mesh) {
|
|
1085
|
+
let mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
1086
|
+
mats.forEach((elem) => {
|
|
1087
|
+
elem.dispose();
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
static disposeMeshGeometry(mesh) {
|
|
1091
|
+
mesh.geometry.dispose();
|
|
1092
|
+
}
|
|
1093
|
+
static disposeMeshResource(mesh) {
|
|
1094
|
+
ThreeObjectLibrary.disposeMeshMaterial(mesh);
|
|
1095
|
+
ThreeObjectLibrary.disposeMeshGeometry(mesh);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1083
1099
|
class World {
|
|
1084
1100
|
get scene() {
|
|
1085
1101
|
return this._scene;
|
|
@@ -1102,6 +1118,18 @@ class World {
|
|
|
1102
1118
|
elem.tick(deltaTime);
|
|
1103
1119
|
});
|
|
1104
1120
|
}
|
|
1121
|
+
destroy() {
|
|
1122
|
+
this.actors.forEach((elem) => {
|
|
1123
|
+
elem.destroy();
|
|
1124
|
+
});
|
|
1125
|
+
this.actors.clear();
|
|
1126
|
+
this.scene.traverse((child) => {
|
|
1127
|
+
if (child instanceof three.Mesh) {
|
|
1128
|
+
ThreeObjectLibrary.disposeMeshResource(child);
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
this.scene.clear();
|
|
1132
|
+
}
|
|
1105
1133
|
addActor(actor) {
|
|
1106
1134
|
if (!actor.rootComponent.threeObject) {
|
|
1107
1135
|
throw Error("actor.threeObject is null");
|
|
@@ -1112,8 +1140,6 @@ class World {
|
|
|
1112
1140
|
actor.onAddedToWorld(this);
|
|
1113
1141
|
this.viewport.markRenderStateDirty();
|
|
1114
1142
|
}
|
|
1115
|
-
destroy() {
|
|
1116
|
-
}
|
|
1117
1143
|
}
|
|
1118
1144
|
|
|
1119
1145
|
const DefaultToneMappingParams = {
|
|
@@ -2024,9 +2050,6 @@ class CameraFactory {
|
|
|
2024
2050
|
}
|
|
2025
2051
|
}
|
|
2026
2052
|
|
|
2027
|
-
const DefaultRenderParam = {
|
|
2028
|
-
antialias: true,
|
|
2029
|
-
};
|
|
2030
2053
|
const DefaultCameraParam = {
|
|
2031
2054
|
near: 0.1,
|
|
2032
2055
|
far: 1000,
|
|
@@ -2035,11 +2058,16 @@ const DefaultCameraParam = {
|
|
|
2035
2058
|
aspect: 1,
|
|
2036
2059
|
}
|
|
2037
2060
|
};
|
|
2061
|
+
|
|
2062
|
+
const DefaultRenderParam = {
|
|
2063
|
+
antialias: true,
|
|
2064
|
+
};
|
|
2038
2065
|
const DefaultAppParam = {
|
|
2039
2066
|
renderParam: DefaultRenderParam,
|
|
2040
2067
|
cameraParam: DefaultCameraParam,
|
|
2041
2068
|
postProcessParam: DefaultPostProcessParam,
|
|
2042
2069
|
};
|
|
2070
|
+
|
|
2043
2071
|
class ThreeJsApp {
|
|
2044
2072
|
get camera() {
|
|
2045
2073
|
return this._camera;
|
|
@@ -2098,6 +2126,12 @@ class ThreeJsApp {
|
|
|
2098
2126
|
this.world.tick(delta);
|
|
2099
2127
|
this.viewport.render();
|
|
2100
2128
|
}
|
|
2129
|
+
destroy() {
|
|
2130
|
+
this.onCameraChangedDelegate.clear();
|
|
2131
|
+
this.world.destroy();
|
|
2132
|
+
this.controller.destroy();
|
|
2133
|
+
this.viewport.destroy();
|
|
2134
|
+
}
|
|
2101
2135
|
updateCamera(param) {
|
|
2102
2136
|
const previousCam = this.camera;
|
|
2103
2137
|
this._camera = CameraFactory.updataCamera(param, this.camera);
|
|
@@ -2116,12 +2150,6 @@ class ThreeJsApp {
|
|
|
2116
2150
|
// }
|
|
2117
2151
|
this.camera.updateProjectionMatrix();
|
|
2118
2152
|
}
|
|
2119
|
-
destroy() {
|
|
2120
|
-
this.onCameraChangedDelegate.clear();
|
|
2121
|
-
this.world.destroy();
|
|
2122
|
-
this.controller.destroy();
|
|
2123
|
-
this.viewport.destroy();
|
|
2124
|
-
}
|
|
2125
2153
|
}
|
|
2126
2154
|
|
|
2127
2155
|
class Actor extends BaseObject {
|
|
@@ -2881,7 +2909,6 @@ exports.BoxComponent = BoxComponent;
|
|
|
2881
2909
|
exports.Controller = Controller;
|
|
2882
2910
|
exports.DefaultAppParam = DefaultAppParam;
|
|
2883
2911
|
exports.DefaultBloomParam = DefaultBloomParam;
|
|
2884
|
-
exports.DefaultCameraParam = DefaultCameraParam;
|
|
2885
2912
|
exports.DefaultDOFParam = DefaultDOFParam;
|
|
2886
2913
|
exports.DefaultDenoiseParam = DefaultDenoiseParam;
|
|
2887
2914
|
exports.DefaultGTAOParam = DefaultGTAOParam;
|
|
@@ -2904,6 +2931,7 @@ exports.PlaneComponent = PlaneComponent;
|
|
|
2904
2931
|
exports.SceneComponent = SceneComponent;
|
|
2905
2932
|
exports.SphereComponent = SphereComponent;
|
|
2906
2933
|
exports.ThreeJsApp = ThreeJsApp;
|
|
2934
|
+
exports.ThreeObjectLibrary = ThreeObjectLibrary;
|
|
2907
2935
|
exports.ToneMappingOptions = ToneMappingOptions;
|
|
2908
2936
|
exports.TransformGizmo = TransformGizmo;
|
|
2909
2937
|
exports.Viewport = Viewport;
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1078,6 +1078,22 @@ const DefaultPostProcessParam = {
|
|
|
1078
1078
|
}
|
|
1079
1079
|
};
|
|
1080
1080
|
|
|
1081
|
+
class ThreeObjectLibrary {
|
|
1082
|
+
static disposeMeshMaterial(mesh) {
|
|
1083
|
+
let mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
1084
|
+
mats.forEach((elem) => {
|
|
1085
|
+
elem.dispose();
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
static disposeMeshGeometry(mesh) {
|
|
1089
|
+
mesh.geometry.dispose();
|
|
1090
|
+
}
|
|
1091
|
+
static disposeMeshResource(mesh) {
|
|
1092
|
+
ThreeObjectLibrary.disposeMeshMaterial(mesh);
|
|
1093
|
+
ThreeObjectLibrary.disposeMeshGeometry(mesh);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1081
1097
|
class World {
|
|
1082
1098
|
get scene() {
|
|
1083
1099
|
return this._scene;
|
|
@@ -1100,6 +1116,18 @@ class World {
|
|
|
1100
1116
|
elem.tick(deltaTime);
|
|
1101
1117
|
});
|
|
1102
1118
|
}
|
|
1119
|
+
destroy() {
|
|
1120
|
+
this.actors.forEach((elem) => {
|
|
1121
|
+
elem.destroy();
|
|
1122
|
+
});
|
|
1123
|
+
this.actors.clear();
|
|
1124
|
+
this.scene.traverse((child) => {
|
|
1125
|
+
if (child instanceof Mesh) {
|
|
1126
|
+
ThreeObjectLibrary.disposeMeshResource(child);
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
this.scene.clear();
|
|
1130
|
+
}
|
|
1103
1131
|
addActor(actor) {
|
|
1104
1132
|
if (!actor.rootComponent.threeObject) {
|
|
1105
1133
|
throw Error("actor.threeObject is null");
|
|
@@ -1110,8 +1138,6 @@ class World {
|
|
|
1110
1138
|
actor.onAddedToWorld(this);
|
|
1111
1139
|
this.viewport.markRenderStateDirty();
|
|
1112
1140
|
}
|
|
1113
|
-
destroy() {
|
|
1114
|
-
}
|
|
1115
1141
|
}
|
|
1116
1142
|
|
|
1117
1143
|
const DefaultToneMappingParams = {
|
|
@@ -2022,9 +2048,6 @@ class CameraFactory {
|
|
|
2022
2048
|
}
|
|
2023
2049
|
}
|
|
2024
2050
|
|
|
2025
|
-
const DefaultRenderParam = {
|
|
2026
|
-
antialias: true,
|
|
2027
|
-
};
|
|
2028
2051
|
const DefaultCameraParam = {
|
|
2029
2052
|
near: 0.1,
|
|
2030
2053
|
far: 1000,
|
|
@@ -2033,11 +2056,16 @@ const DefaultCameraParam = {
|
|
|
2033
2056
|
aspect: 1,
|
|
2034
2057
|
}
|
|
2035
2058
|
};
|
|
2059
|
+
|
|
2060
|
+
const DefaultRenderParam = {
|
|
2061
|
+
antialias: true,
|
|
2062
|
+
};
|
|
2036
2063
|
const DefaultAppParam = {
|
|
2037
2064
|
renderParam: DefaultRenderParam,
|
|
2038
2065
|
cameraParam: DefaultCameraParam,
|
|
2039
2066
|
postProcessParam: DefaultPostProcessParam,
|
|
2040
2067
|
};
|
|
2068
|
+
|
|
2041
2069
|
class ThreeJsApp {
|
|
2042
2070
|
get camera() {
|
|
2043
2071
|
return this._camera;
|
|
@@ -2096,6 +2124,12 @@ class ThreeJsApp {
|
|
|
2096
2124
|
this.world.tick(delta);
|
|
2097
2125
|
this.viewport.render();
|
|
2098
2126
|
}
|
|
2127
|
+
destroy() {
|
|
2128
|
+
this.onCameraChangedDelegate.clear();
|
|
2129
|
+
this.world.destroy();
|
|
2130
|
+
this.controller.destroy();
|
|
2131
|
+
this.viewport.destroy();
|
|
2132
|
+
}
|
|
2099
2133
|
updateCamera(param) {
|
|
2100
2134
|
const previousCam = this.camera;
|
|
2101
2135
|
this._camera = CameraFactory.updataCamera(param, this.camera);
|
|
@@ -2114,12 +2148,6 @@ class ThreeJsApp {
|
|
|
2114
2148
|
// }
|
|
2115
2149
|
this.camera.updateProjectionMatrix();
|
|
2116
2150
|
}
|
|
2117
|
-
destroy() {
|
|
2118
|
-
this.onCameraChangedDelegate.clear();
|
|
2119
|
-
this.world.destroy();
|
|
2120
|
-
this.controller.destroy();
|
|
2121
|
-
this.viewport.destroy();
|
|
2122
|
-
}
|
|
2123
2151
|
}
|
|
2124
2152
|
|
|
2125
2153
|
class Actor extends BaseObject {
|
|
@@ -2873,4 +2901,4 @@ class TransformGizmo extends Pawn {
|
|
|
2873
2901
|
}
|
|
2874
2902
|
}
|
|
2875
2903
|
|
|
2876
|
-
export { Actor, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAppParam, DefaultBloomParam,
|
|
2904
|
+
export { Actor, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAppParam, DefaultBloomParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOutlineParams, DefaultPostProcessParam, DefaultRenderParam, DefaultSSRParam, DefaultToneMappingParams, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, LYAssetManager, LYLoadTask, LabelComponent, MeshComponent, Orbital, PlaneActor, PlaneComponent, SceneComponent, SphereComponent, ThreeJsApp, ThreeObjectLibrary, ToneMappingOptions, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ export { LYLoadTask } from "./lythreeframe/AssetManagement/Task/Task";
|
|
|
2
2
|
export { LYAssetManager } from "./lythreeframe/AssetManagement/AssetManager";
|
|
3
3
|
export { AttachmentRules } from "./lythreeframe/Defines";
|
|
4
4
|
export { Delegate } from "./lythreeframe/Delegate";
|
|
5
|
-
export { ThreeJsApp,
|
|
6
|
-
export type { AppParam } from "./lythreeframe/ThreeJsApp";
|
|
5
|
+
export { ThreeJsApp, } from "./lythreeframe/ThreeJsApp";
|
|
7
6
|
export { Controller } from "./lythreeframe/Frame/Controller";
|
|
8
7
|
export { Viewport } from "./lythreeframe/Frame/Viewport";
|
|
9
8
|
export { World } from "./lythreeframe/Frame/World";
|
|
10
|
-
export type { CameraParam } from
|
|
9
|
+
export type { CameraParam } from './lythreeframe/Frame/Parameters/CameraParameter';
|
|
10
|
+
export type { DefaultCameraParam } from './lythreeframe/Frame/Parameters/CameraParameter';
|
|
11
|
+
export type { AppParam } from "./lythreeframe/Frame/Parameters/AppParameter";
|
|
12
|
+
export { DefaultRenderParam, DefaultAppParam } from "./lythreeframe/Frame/Parameters/AppParameter";
|
|
11
13
|
export { Actor } from "./lythreeframe/Object/Actor";
|
|
12
14
|
export { DirectionalLightActor } from "./lythreeframe/Object/Actors/Light/DirectionalLightActor";
|
|
13
15
|
export { BoxActor } from "./lythreeframe/Object/Actors/Shape/BoxActor";
|
|
@@ -41,3 +43,4 @@ export { FirstPerson } from "./lythreeframe/Object/PawnV2/FirstPerson";
|
|
|
41
43
|
export type { ITransforming } from "./lythreeframe/Object/PawnV2/TransformControl";
|
|
42
44
|
export { TransformType } from "./lythreeframe/Object/PawnV2/TransformControl";
|
|
43
45
|
export { TransformGizmo } from "./lythreeframe/Object/PawnV2/TransformControl";
|
|
46
|
+
export { ThreeObjectLibrary } from "./lythreeframe/Library/ResourceLibrary";
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { OrthographicCamera, PerspectiveCamera } from "three";
|
|
2
|
-
|
|
3
|
-
near: number;
|
|
4
|
-
far: number;
|
|
5
|
-
param: PerspectiveCameraParam | OrthographicCameraParam;
|
|
6
|
-
}
|
|
7
|
-
export interface PerspectiveCameraParam {
|
|
8
|
-
fov: number;
|
|
9
|
-
aspect: number;
|
|
10
|
-
}
|
|
11
|
-
export interface OrthographicCameraParam {
|
|
12
|
-
left: number;
|
|
13
|
-
right: number;
|
|
14
|
-
top: number;
|
|
15
|
-
bottom: number;
|
|
16
|
-
}
|
|
2
|
+
import { CameraParam } from "../Frame/Parameters/CameraParameter";
|
|
17
3
|
export declare class CameraFactory {
|
|
18
4
|
static createCamera(param: CameraParam): PerspectiveCamera | OrthographicCamera;
|
|
19
5
|
static updataCamera(param: CameraParam, camera: PerspectiveCamera | OrthographicCamera): PerspectiveCamera | OrthographicCamera;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WebGPURendererParameters } from "three/src/renderers/webgpu/WebGPURenderer";
|
|
2
|
+
import { CameraParam } from "./CameraParameter";
|
|
3
|
+
import { PostProcessParam } from "@/lythreeframe/PostProcess/PostProcessParam";
|
|
4
|
+
import { WorldParam } from "./WorldParameter";
|
|
5
|
+
export interface AppParam {
|
|
6
|
+
renderParam?: WebGPURendererParameters;
|
|
7
|
+
cameraParam?: CameraParam;
|
|
8
|
+
postProcessParam?: PostProcessParam;
|
|
9
|
+
worldParam?: WorldParam;
|
|
10
|
+
}
|
|
11
|
+
export declare const DefaultRenderParam: WebGPURendererParameters;
|
|
12
|
+
export declare const DefaultAppParam: AppParam;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface CameraParam {
|
|
2
|
+
near: number;
|
|
3
|
+
far: number;
|
|
4
|
+
param: PerspectiveCameraParam | OrthographicCameraParam;
|
|
5
|
+
}
|
|
6
|
+
export interface PerspectiveCameraParam {
|
|
7
|
+
fov: number;
|
|
8
|
+
aspect: number;
|
|
9
|
+
}
|
|
10
|
+
export interface OrthographicCameraParam {
|
|
11
|
+
left: number;
|
|
12
|
+
right: number;
|
|
13
|
+
top: number;
|
|
14
|
+
bottom: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const DefaultCameraParam: CameraParam;
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import { PostProcessParam } from './PostProcess/PostProcessParam';
|
|
2
1
|
import { World } from "./Frame/World";
|
|
3
2
|
import { Viewport } from "./Frame/Viewport";
|
|
4
3
|
import { Controller } from "./Frame/Controller";
|
|
5
4
|
import { Clock, OrthographicCamera, PerspectiveCamera } from "three";
|
|
6
|
-
import { CameraParam } from "./Factory/CameraFactory";
|
|
7
|
-
import { WebGPURendererParameters } from 'three/src/renderers/webgpu/WebGPURenderer.js';
|
|
8
5
|
import { Delegate } from './Delegate';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
cameraParam?: CameraParam;
|
|
12
|
-
postProcessParam?: PostProcessParam;
|
|
13
|
-
}
|
|
14
|
-
export declare const DefaultRenderParam: WebGPURendererParameters;
|
|
15
|
-
export declare const DefaultCameraParam: CameraParam;
|
|
16
|
-
export declare const DefaultAppParam: AppParam;
|
|
6
|
+
import { CameraParam } from './Frame/Parameters/CameraParameter';
|
|
7
|
+
import { AppParam } from './Frame/Parameters/AppParameter';
|
|
17
8
|
export declare class ThreeJsApp {
|
|
18
9
|
get camera(): PerspectiveCamera | OrthographicCamera;
|
|
19
10
|
get clock(): Clock;
|
|
@@ -35,7 +26,7 @@ export declare class ThreeJsApp {
|
|
|
35
26
|
constructor(elementId: string, appParam?: AppParam);
|
|
36
27
|
init(): void;
|
|
37
28
|
tick(): void;
|
|
29
|
+
destroy(): void;
|
|
38
30
|
updateCamera(param: CameraParam): void;
|
|
39
31
|
onWindowResize(width: number, height: number): void;
|
|
40
|
-
destroy(): void;
|
|
41
32
|
}
|