lythreeframe 1.0.23 → 1.0.25

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.
@@ -14,6 +14,7 @@ var MotionBlur_js = require('three/examples/jsm/tsl/display/MotionBlur.js');
14
14
  var FXAANode_js = require('three/examples/jsm/tsl/display/FXAANode.js');
15
15
  var SMAANode_js = require('three/examples/jsm/tsl/display/SMAANode.js');
16
16
  var gsap = require('gsap');
17
+ var SkyMesh_js = require('three/examples/jsm/objects/SkyMesh.js');
17
18
  var CSS2DRenderer_js = require('three/examples/jsm/renderers/CSS2DRenderer.js');
18
19
  var PointerLockControls = require('three/examples/jsm/controls/PointerLockControls');
19
20
  var TransformControls_js = require('three/examples/jsm/controls/TransformControls.js');
@@ -2613,9 +2614,19 @@ class DirectionalLightComponent extends LightComponent {
2613
2614
  class DirectionalLightActor extends Actor {
2614
2615
  constructor(color = 0xffffff, intensity = 1) {
2615
2616
  super();
2616
- this.lightComponent = new DirectionalLightComponent(color, intensity);
2617
+ this.lightComponent = null;
2618
+ this.lightComponent = this.rootComponent;
2619
+ if (this.lightComponent) {
2620
+ this.lightComponent.color = color;
2621
+ this.lightComponent.intensity = intensity;
2622
+ }
2623
+ this.lightComponent.castShadow = true;
2624
+ }
2625
+ constructRootComponent() {
2626
+ this.lightComponent = new DirectionalLightComponent();
2617
2627
  this.rootComponent = this.lightComponent;
2618
2628
  this.lightComponent.castShadow = true;
2629
+ this.rootComponent.parentActor = this;
2619
2630
  }
2620
2631
  }
2621
2632
 
@@ -2632,6 +2643,69 @@ class BoxActor extends Actor {
2632
2643
  }
2633
2644
  }
2634
2645
 
2646
+ const DefaultSkyParam = {
2647
+ turbidity: 10,
2648
+ rayleigh: 3,
2649
+ mieCoefficient: 0.005,
2650
+ mieDirectionalG: 0.7,
2651
+ elevation: 2,
2652
+ azimuth: 135,
2653
+ };
2654
+ class SkyComponent extends SceneComponent {
2655
+ get threeObject() {
2656
+ if (!this.obj) {
2657
+ throw Error("three object is invalid");
2658
+ }
2659
+ return this.obj;
2660
+ }
2661
+ set threeObject(newThreeObject) {
2662
+ this.obj = newThreeObject;
2663
+ if (this.obj) {
2664
+ this.obj.userData["LYObject"] = this;
2665
+ }
2666
+ }
2667
+ constructor(skyparam) {
2668
+ let obj = new SkyMesh_js.SkyMesh();
2669
+ super(obj);
2670
+ this.skyParam = DefaultSkyParam;
2671
+ this.sunPosition = new webgpu.Vector3();
2672
+ this.obj = obj;
2673
+ this.name = "SkyComponent";
2674
+ if (skyparam) {
2675
+ this.skyParam = skyparam;
2676
+ }
2677
+ this.updateSky();
2678
+ }
2679
+ updateSky() {
2680
+ var _a, _b;
2681
+ this.threeObject.turbidity.value = this.skyParam.turbidity;
2682
+ this.threeObject.rayleigh.value = this.skyParam.rayleigh;
2683
+ this.threeObject.mieCoefficient.value = this.skyParam.mieCoefficient;
2684
+ this.threeObject.mieDirectionalG.value = this.skyParam.mieDirectionalG;
2685
+ const phi = webgpu.MathUtils.degToRad(90 - this.skyParam.elevation);
2686
+ const theta = webgpu.MathUtils.degToRad(this.skyParam.azimuth);
2687
+ this.sunPosition.setFromSphericalCoords(1, phi, theta);
2688
+ this.threeObject.sunPosition.value.copy(this.sunPosition);
2689
+ (_b = (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport) === null || _b === void 0 ? void 0 : _b.markRenderStateDirty();
2690
+ }
2691
+ }
2692
+
2693
+ class SkyActor extends Actor {
2694
+ constructor() {
2695
+ super();
2696
+ this._name = "SkyActor";
2697
+ this.skyComponent = null;
2698
+ this.name = "DirectionalLightActor";
2699
+ this.skyComponent = this.rootComponent;
2700
+ this.rootComponent.name = `${this.rootComponent.name}(Root)`;
2701
+ }
2702
+ constructRootComponent() {
2703
+ this.skyComponent = new SkyComponent();
2704
+ this.rootComponent = this.skyComponent;
2705
+ this.rootComponent.parentActor = this;
2706
+ }
2707
+ }
2708
+
2635
2709
  class PlaneComponent extends MeshComponent {
2636
2710
  constructor(width, height, material, widthSegments = 1, heightSegments = 1) {
2637
2711
  super(new webgpu.PlaneGeometry(width, height, widthSegments, heightSegments), material);
@@ -2657,41 +2731,6 @@ class PlaneActor extends Actor {
2657
2731
  }
2658
2732
  }
2659
2733
 
2660
- const DefaultBloomParam = {
2661
- threshold: 0,
2662
- strength: 1,
2663
- radius: 0,
2664
- };
2665
-
2666
- const DefaultDenoiseParam = {
2667
- denoiseRadius: 5,
2668
- lumaPhi: 5,
2669
- depthPhi: 5,
2670
- normalPhi: 5
2671
- };
2672
-
2673
- const DefaultDOFParam = {
2674
- focus: 500.0,
2675
- aperture: 5,
2676
- maxblur: 0.01
2677
- };
2678
-
2679
- const DefaultGTAOParam = {
2680
- distanceExponent: 1,
2681
- distanceFallOff: 1,
2682
- radius: 0.25,
2683
- scale: 1,
2684
- thickness: 1,
2685
- denoised: true,
2686
- denoiseParam: DefaultDenoiseParam,
2687
- };
2688
-
2689
- const DefaultSSRParam = {
2690
- maxDistance: 0.5,
2691
- opacity: 1,
2692
- thickness: 0.015,
2693
- };
2694
-
2695
2734
  class SphereComponent extends MeshComponent {
2696
2735
  constructor(radius, material = new webgpu.MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
2697
2736
  super(new webgpu.SphereGeometry(radius, widthSegments, heightSegments), material);
@@ -2741,6 +2780,41 @@ class LabelComponent extends SceneComponent {
2741
2780
  // labelStyle.style.fontSize = "10px";
2742
2781
  // labelStyle.style.pointerEvents = 'auto';
2743
2782
 
2783
+ const DefaultBloomParam = {
2784
+ threshold: 0,
2785
+ strength: 1,
2786
+ radius: 0,
2787
+ };
2788
+
2789
+ const DefaultDenoiseParam = {
2790
+ denoiseRadius: 5,
2791
+ lumaPhi: 5,
2792
+ depthPhi: 5,
2793
+ normalPhi: 5
2794
+ };
2795
+
2796
+ const DefaultDOFParam = {
2797
+ focus: 500.0,
2798
+ aperture: 5,
2799
+ maxblur: 0.01
2800
+ };
2801
+
2802
+ const DefaultGTAOParam = {
2803
+ distanceExponent: 1,
2804
+ distanceFallOff: 1,
2805
+ radius: 0.25,
2806
+ scale: 1,
2807
+ thickness: 1,
2808
+ denoised: true,
2809
+ denoiseParam: DefaultDenoiseParam,
2810
+ };
2811
+
2812
+ const DefaultSSRParam = {
2813
+ maxDistance: 0.5,
2814
+ opacity: 1,
2815
+ thickness: 0.015,
2816
+ };
2817
+
2744
2818
  class FirstPerson extends Pawn {
2745
2819
  constructor(controller) {
2746
2820
  super(controller);
@@ -2915,6 +2989,7 @@ exports.DefaultOutlineParams = DefaultOutlineParams;
2915
2989
  exports.DefaultPostProcessParam = DefaultPostProcessParam;
2916
2990
  exports.DefaultRenderParam = DefaultRenderParam;
2917
2991
  exports.DefaultSSRParam = DefaultSSRParam;
2992
+ exports.DefaultSkyParam = DefaultSkyParam;
2918
2993
  exports.DefaultToneMappingParams = DefaultToneMappingParams;
2919
2994
  exports.Delegate = Delegate;
2920
2995
  exports.DirectionalLightActor = DirectionalLightActor;
@@ -2928,6 +3003,8 @@ exports.Orbital = Orbital;
2928
3003
  exports.PlaneActor = PlaneActor;
2929
3004
  exports.PlaneComponent = PlaneComponent;
2930
3005
  exports.SceneComponent = SceneComponent;
3006
+ exports.SkyActor = SkyActor;
3007
+ exports.SkyComponent = SkyComponent;
2931
3008
  exports.SphereComponent = SphereComponent;
2932
3009
  exports.ThreeJsApp = ThreeJsApp;
2933
3010
  exports.ThreeObjectLibrary = ThreeObjectLibrary;
@@ -12,6 +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 { SkyMesh } from 'three/examples/jsm/objects/SkyMesh.js';
15
16
  import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
16
17
  import { PointerLockControls } from 'three/examples/jsm/controls/PointerLockControls';
17
18
  import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
@@ -2611,9 +2612,19 @@ class DirectionalLightComponent extends LightComponent {
2611
2612
  class DirectionalLightActor extends Actor {
2612
2613
  constructor(color = 0xffffff, intensity = 1) {
2613
2614
  super();
2614
- this.lightComponent = new DirectionalLightComponent(color, intensity);
2615
+ this.lightComponent = null;
2616
+ this.lightComponent = this.rootComponent;
2617
+ if (this.lightComponent) {
2618
+ this.lightComponent.color = color;
2619
+ this.lightComponent.intensity = intensity;
2620
+ }
2621
+ this.lightComponent.castShadow = true;
2622
+ }
2623
+ constructRootComponent() {
2624
+ this.lightComponent = new DirectionalLightComponent();
2615
2625
  this.rootComponent = this.lightComponent;
2616
2626
  this.lightComponent.castShadow = true;
2627
+ this.rootComponent.parentActor = this;
2617
2628
  }
2618
2629
  }
2619
2630
 
@@ -2630,6 +2641,69 @@ class BoxActor extends Actor {
2630
2641
  }
2631
2642
  }
2632
2643
 
2644
+ const DefaultSkyParam = {
2645
+ turbidity: 10,
2646
+ rayleigh: 3,
2647
+ mieCoefficient: 0.005,
2648
+ mieDirectionalG: 0.7,
2649
+ elevation: 2,
2650
+ azimuth: 135,
2651
+ };
2652
+ class SkyComponent extends SceneComponent {
2653
+ get threeObject() {
2654
+ if (!this.obj) {
2655
+ throw Error("three object is invalid");
2656
+ }
2657
+ return this.obj;
2658
+ }
2659
+ set threeObject(newThreeObject) {
2660
+ this.obj = newThreeObject;
2661
+ if (this.obj) {
2662
+ this.obj.userData["LYObject"] = this;
2663
+ }
2664
+ }
2665
+ constructor(skyparam) {
2666
+ let obj = new SkyMesh();
2667
+ super(obj);
2668
+ this.skyParam = DefaultSkyParam;
2669
+ this.sunPosition = new Vector3();
2670
+ this.obj = obj;
2671
+ this.name = "SkyComponent";
2672
+ if (skyparam) {
2673
+ this.skyParam = skyparam;
2674
+ }
2675
+ this.updateSky();
2676
+ }
2677
+ updateSky() {
2678
+ var _a, _b;
2679
+ this.threeObject.turbidity.value = this.skyParam.turbidity;
2680
+ this.threeObject.rayleigh.value = this.skyParam.rayleigh;
2681
+ this.threeObject.mieCoefficient.value = this.skyParam.mieCoefficient;
2682
+ this.threeObject.mieDirectionalG.value = this.skyParam.mieDirectionalG;
2683
+ const phi = MathUtils.degToRad(90 - this.skyParam.elevation);
2684
+ const theta = MathUtils.degToRad(this.skyParam.azimuth);
2685
+ this.sunPosition.setFromSphericalCoords(1, phi, theta);
2686
+ this.threeObject.sunPosition.value.copy(this.sunPosition);
2687
+ (_b = (_a = this.world) === null || _a === void 0 ? void 0 : _a.viewport) === null || _b === void 0 ? void 0 : _b.markRenderStateDirty();
2688
+ }
2689
+ }
2690
+
2691
+ class SkyActor extends Actor {
2692
+ constructor() {
2693
+ super();
2694
+ this._name = "SkyActor";
2695
+ this.skyComponent = null;
2696
+ this.name = "DirectionalLightActor";
2697
+ this.skyComponent = this.rootComponent;
2698
+ this.rootComponent.name = `${this.rootComponent.name}(Root)`;
2699
+ }
2700
+ constructRootComponent() {
2701
+ this.skyComponent = new SkyComponent();
2702
+ this.rootComponent = this.skyComponent;
2703
+ this.rootComponent.parentActor = this;
2704
+ }
2705
+ }
2706
+
2633
2707
  class PlaneComponent extends MeshComponent {
2634
2708
  constructor(width, height, material, widthSegments = 1, heightSegments = 1) {
2635
2709
  super(new PlaneGeometry(width, height, widthSegments, heightSegments), material);
@@ -2655,41 +2729,6 @@ class PlaneActor extends Actor {
2655
2729
  }
2656
2730
  }
2657
2731
 
2658
- const DefaultBloomParam = {
2659
- threshold: 0,
2660
- strength: 1,
2661
- radius: 0,
2662
- };
2663
-
2664
- const DefaultDenoiseParam = {
2665
- denoiseRadius: 5,
2666
- lumaPhi: 5,
2667
- depthPhi: 5,
2668
- normalPhi: 5
2669
- };
2670
-
2671
- const DefaultDOFParam = {
2672
- focus: 500.0,
2673
- aperture: 5,
2674
- maxblur: 0.01
2675
- };
2676
-
2677
- const DefaultGTAOParam = {
2678
- distanceExponent: 1,
2679
- distanceFallOff: 1,
2680
- radius: 0.25,
2681
- scale: 1,
2682
- thickness: 1,
2683
- denoised: true,
2684
- denoiseParam: DefaultDenoiseParam,
2685
- };
2686
-
2687
- const DefaultSSRParam = {
2688
- maxDistance: 0.5,
2689
- opacity: 1,
2690
- thickness: 0.015,
2691
- };
2692
-
2693
2732
  class SphereComponent extends MeshComponent {
2694
2733
  constructor(radius, material = new MeshBasicMaterial(), widthSegments = 32, heightSegments = 16) {
2695
2734
  super(new SphereGeometry(radius, widthSegments, heightSegments), material);
@@ -2739,6 +2778,41 @@ class LabelComponent extends SceneComponent {
2739
2778
  // labelStyle.style.fontSize = "10px";
2740
2779
  // labelStyle.style.pointerEvents = 'auto';
2741
2780
 
2781
+ const DefaultBloomParam = {
2782
+ threshold: 0,
2783
+ strength: 1,
2784
+ radius: 0,
2785
+ };
2786
+
2787
+ const DefaultDenoiseParam = {
2788
+ denoiseRadius: 5,
2789
+ lumaPhi: 5,
2790
+ depthPhi: 5,
2791
+ normalPhi: 5
2792
+ };
2793
+
2794
+ const DefaultDOFParam = {
2795
+ focus: 500.0,
2796
+ aperture: 5,
2797
+ maxblur: 0.01
2798
+ };
2799
+
2800
+ const DefaultGTAOParam = {
2801
+ distanceExponent: 1,
2802
+ distanceFallOff: 1,
2803
+ radius: 0.25,
2804
+ scale: 1,
2805
+ thickness: 1,
2806
+ denoised: true,
2807
+ denoiseParam: DefaultDenoiseParam,
2808
+ };
2809
+
2810
+ const DefaultSSRParam = {
2811
+ maxDistance: 0.5,
2812
+ opacity: 1,
2813
+ thickness: 0.015,
2814
+ };
2815
+
2742
2816
  class FirstPerson extends Pawn {
2743
2817
  constructor(controller) {
2744
2818
  super(controller);
@@ -2900,4 +2974,4 @@ class TransformGizmo extends Pawn {
2900
2974
  }
2901
2975
  }
2902
2976
 
2903
- 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 };
2977
+ export { Actor, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAppParam, DefaultBloomParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOutlineParams, DefaultPostProcessParam, DefaultRenderParam, DefaultSSRParam, DefaultSkyParam, DefaultToneMappingParams, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, LYAssetManager, LYLoadTask, LabelComponent, MeshComponent, Orbital, PlaneActor, PlaneComponent, SceneComponent, SkyActor, SkyComponent, SphereComponent, ThreeJsApp, ThreeObjectLibrary, ToneMappingOptions, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
package/dist/index.d.ts CHANGED
@@ -13,7 +13,18 @@ export { DefaultRenderParam, DefaultAppParam } from "./lythreeframe/Frame/Parame
13
13
  export { Actor } from "./lythreeframe/Object/Actor";
14
14
  export { DirectionalLightActor } from "./lythreeframe/Object/Actors/Light/DirectionalLightActor";
15
15
  export { BoxActor } from "./lythreeframe/Object/Actors/Shape/BoxActor";
16
+ export { SkyActor } from "./lythreeframe/Object/Actors/Sky/SkyActor";
16
17
  export { PlaneActor } from "./lythreeframe/Object/Actors/Shape/PlaneActor";
18
+ export { SceneComponent } from "./lythreeframe/Object/Components/SceneComponent";
19
+ export { MeshComponent } from "./lythreeframe/Object/Components/Mesh/MeshComponent";
20
+ export { BoxComponent } from "./lythreeframe/Object/Components/Mesh/Shape/BoxComponent";
21
+ export { PlaneComponent } from "./lythreeframe/Object/Components/Mesh/Shape/PlaneComponent";
22
+ export { SphereComponent } from "./lythreeframe/Object/Components/Mesh/Shape/SphereComponent";
23
+ export { DirectionalLightComponent } from "./lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent";
24
+ export { LabelComponent } from "./lythreeframe/Object/Components/2D/2DComponent";
25
+ export { SkyComponent } from "./lythreeframe/Object/Components/Sky/SkyComponent";
26
+ export type { SkyComponentParam } from "./lythreeframe/Object/Components/Sky/SkyComponent";
27
+ export { DefaultSkyParam } from "./lythreeframe/Object/Components/Sky/SkyComponent";
17
28
  export { WebGPUPostProcessFactory } from "./lythreeframe/PostProcess/WebGPUPostProcessFactory";
18
29
  export { DefaultPostProcessParam } from "./lythreeframe/PostProcess/PostProcessParam";
19
30
  export type { PostProcessParam } from "./lythreeframe/PostProcess/PostProcessParam";
@@ -31,13 +42,6 @@ export { DefaultSSRParam } from "./lythreeframe/PostProcess/Param/SSR";
31
42
  export type { SSRParam } from "./lythreeframe/PostProcess/Param/SSR";
32
43
  export { DefaultToneMappingParams, ToneMappingOptions } from "./lythreeframe/PostProcess/Param/ToneMapping";
33
44
  export type { ToneMappingParams } from "./lythreeframe/PostProcess/Param/ToneMapping";
34
- export { SceneComponent } from "./lythreeframe/Object/Components/SceneComponent";
35
- export { MeshComponent } from "./lythreeframe/Object/Components/Mesh/MeshComponent";
36
- export { BoxComponent } from "./lythreeframe/Object/Components/Mesh/Shape/BoxComponent";
37
- export { PlaneComponent } from "./lythreeframe/Object/Components/Mesh/Shape/PlaneComponent";
38
- export { SphereComponent } from "./lythreeframe/Object/Components/Mesh/Shape/SphereComponent";
39
- export { DirectionalLightComponent } from "./lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent";
40
- export { LabelComponent } from "./lythreeframe/Object/Components/2D/2DComponent";
41
45
  export { Orbital } from "./lythreeframe/Object/PawnV2/Oribital";
42
46
  export { FirstPerson } from "./lythreeframe/Object/PawnV2/FirstPerson";
43
47
  export type { ITransforming } from "./lythreeframe/Object/PawnV2/TransformControl";
@@ -2,6 +2,7 @@ import { ColorRepresentation } from "three/webgpu";
2
2
  import { Actor } from "../../Actor";
3
3
  import { DirectionalLightComponent } from "../../Components/Light/DirectionalLight/DirectionalLightComponent";
4
4
  export declare class DirectionalLightActor extends Actor {
5
- protected lightComponent: DirectionalLightComponent;
5
+ protected lightComponent: DirectionalLightComponent | null;
6
6
  constructor(color?: ColorRepresentation, intensity?: number);
7
+ protected constructRootComponent(): void;
7
8
  }
@@ -1,8 +1,8 @@
1
- import { EditorSkyComponent } from "@editor/Object/Components/Sky/EditorSkyComponent";
2
- import { EditorActor } from "../EditorActor";
3
- export declare class EditorSkyActor extends EditorActor {
1
+ import { Actor } from "../../Actor";
2
+ import { SkyComponent } from "../../Components/Sky/SkyComponent";
3
+ export declare class SkyActor extends Actor {
4
4
  protected _name: string;
5
- protected skyComponent: EditorSkyComponent | null;
5
+ protected skyComponent: SkyComponent | null;
6
6
  constructor();
7
7
  protected constructRootComponent(): void;
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",