lythreeframe 1.0.6 → 1.0.8

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/LICENSE CHANGED
@@ -1,8 +1,21 @@
1
1
  MIT License
2
- Copyright (c) <year> <copyright holders>
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ Copyright (c) 2025 Noegip
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
7
11
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -2,13 +2,12 @@
2
2
 
3
3
  var three = require('three');
4
4
  var Addons_js = require('three/examples/jsm/Addons.js');
5
- var Nodes_js = require('three/examples/jsm/nodes/Nodes.js');
6
- var WebGPURenderer_js = require('three/examples/jsm/renderers/webgpu/WebGPURenderer.js');
5
+ var tsl = require('three/tsl');
6
+ var webgpu = require('three/webgpu');
7
7
  var BloomNode_js = require('three/examples/jsm/tsl/display/BloomNode.js');
8
8
  var DenoiseNode_js = require('three/examples/jsm/tsl/display/DenoiseNode.js');
9
9
  var DepthOfFieldNode_js = require('three/examples/jsm/tsl/display/DepthOfFieldNode.js');
10
10
  var GTAONode_js = require('three/examples/jsm/tsl/display/GTAONode.js');
11
- var tsl = require('three/tsl');
12
11
  var SSRNode_js = require('three/examples/jsm/tsl/display/SSRNode.js');
13
12
  var LensflareNode_js = require('three/examples/jsm/tsl/display/LensflareNode.js');
14
13
  var OutlineNode_js = require('three/examples/jsm/tsl/display/OutlineNode.js');
@@ -17,6 +16,7 @@ var FXAANode_js = require('three/examples/jsm/tsl/display/FXAANode.js');
17
16
  var SMAANode_js = require('three/examples/jsm/tsl/display/SMAANode.js');
18
17
  var CSS2DRenderer_js = require('three/examples/jsm/renderers/CSS2DRenderer.js');
19
18
  var PointerLockControls = require('three/examples/jsm/controls/PointerLockControls');
19
+ var TransformControls_js = require('three/examples/jsm/controls/TransformControls.js');
20
20
 
21
21
  class LYLoadTask {
22
22
  constructor(paths, onLoaded) {
@@ -1326,7 +1326,7 @@ class Viewport {
1326
1326
  if (!element) {
1327
1327
  throw Error(`Can not find domElement which id is ${elementId}`);
1328
1328
  }
1329
- this._renderer = new WebGPURenderer_js.WebGPURenderer(rendererParam);
1329
+ this._renderer = new webgpu.WebGPURenderer(rendererParam);
1330
1330
  this._renderer.setPixelRatio(window.devicePixelRatio);
1331
1331
  this._renderer.setSize(element.clientWidth, element.clientHeight);
1332
1332
  this._renderer.shadowMap.enabled = true;
@@ -1364,7 +1364,7 @@ class Viewport {
1364
1364
  return;
1365
1365
  }
1366
1366
  if (!this.postProcessing) {
1367
- this.postProcessing = new WebGPURenderer_js.PostProcessing(this.renderer);
1367
+ this.postProcessing = new webgpu.PostProcessing(this.renderer);
1368
1368
  }
1369
1369
  if (!this.scenePass) {
1370
1370
  this.scenePass = WebGPUPostProcessFactory.constructScenePass(this.app.world.scene, this.app.camera);
@@ -1428,7 +1428,7 @@ class Viewport {
1428
1428
  else {
1429
1429
  WebGPUPostProcessFactory.updateSSRPass(this.ssrPass, this.postProcessParam.ssr);
1430
1430
  }
1431
- finalNode = Nodes_js.blendColor(finalNode, this.ssrPass);
1431
+ finalNode = tsl.blendColor(finalNode, this.ssrPass);
1432
1432
  }
1433
1433
  // GTAO
1434
1434
  if (this.postProcessParam.gtao) {
@@ -1474,10 +1474,10 @@ class Viewport {
1474
1474
  WebGPUPostProcessFactory.updateOutlinePass(this.outlinePass, this.outlineObjects, this.postProcessParam.outline);
1475
1475
  }
1476
1476
  const { visibleEdge, hiddenEdge } = this.outlinePass;
1477
- const pulsePeriod = Nodes_js.uniform(this.postProcessParam.outline.pulsePeriod);
1478
- const period = Nodes_js.time.div(pulsePeriod).mul(2);
1479
- const osc = Nodes_js.oscSine(period).mul(.5).add(.5);
1480
- const outlineColor = visibleEdge.mul(Nodes_js.uniform(new WebGPURenderer_js.Color(this.postProcessParam.outline.visibleEdgeColor))).add(hiddenEdge.mul(Nodes_js.uniform(new WebGPURenderer_js.Color(this.postProcessParam.outline.hiddenEdgeColor)))).mul(this.postProcessParam.outline.edgeStrength);
1477
+ const pulsePeriod = tsl.uniform(this.postProcessParam.outline.pulsePeriod);
1478
+ const period = tsl.time.div(pulsePeriod).mul(2);
1479
+ const osc = tsl.oscSine(period).mul(.5).add(.5);
1480
+ const outlineColor = visibleEdge.mul(tsl.uniform(new webgpu.Color(this.postProcessParam.outline.visibleEdgeColor))).add(hiddenEdge.mul(tsl.uniform(new webgpu.Color(this.postProcessParam.outline.hiddenEdgeColor)))).mul(this.postProcessParam.outline.edgeStrength);
1481
1481
  const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
1482
1482
  // if(!this.denoiseOutlinePass)
1483
1483
  // {
@@ -2611,6 +2611,160 @@ class FirstPerson extends Pawn {
2611
2611
  }
2612
2612
  }
2613
2613
 
2614
+ class TransformGizmo extends Pawn {
2615
+ get control() {
2616
+ if (!this._control) {
2617
+ throw new Error("Control not initialized");
2618
+ }
2619
+ return this._control;
2620
+ }
2621
+ constructor(controller) {
2622
+ super(controller);
2623
+ this._control = null;
2624
+ this.helperObject = new three.Object3D();
2625
+ this.targets = [];
2626
+ this.primaryTarget = null;
2627
+ this.targetMatrixMap = new Map();
2628
+ this.onDraggingChangedEvent = (param) => { this.onDraggingChanged(param); };
2629
+ this.onObjectChangeEvent = () => { this.onObjectChanged(); };
2630
+ this.onChangeEvent = () => { this.onChange(); };
2631
+ this.onUpdateFunctions = [];
2632
+ this.onDraggingFunctions = [];
2633
+ this._control = new TransformControls_js.TransformControls(controller.camera, controller.viewPort.canvas);
2634
+ this.control.getHelper().traverse((elem) => {
2635
+ elem.userData["rayIgnored"] = true;
2636
+ });
2637
+ this.helperObject.name = "TransformHelperObject";
2638
+ }
2639
+ possess() {
2640
+ var _a;
2641
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.add(this.helperObject);
2642
+ this.control.attach(this.helperObject);
2643
+ this.control.addEventListener('change', this.onChangeEvent);
2644
+ this.control.addEventListener('dragging-changed', this.onDraggingChangedEvent);
2645
+ this.control.addEventListener('objectChange', this.onObjectChangeEvent);
2646
+ }
2647
+ unpossess() {
2648
+ var _a;
2649
+ this.control.removeEventListener('change', this.onChangeEvent);
2650
+ this.control.removeEventListener('dragging-changed', this.onDraggingChangedEvent);
2651
+ this.control.removeEventListener('objectChange', this.onObjectChangeEvent);
2652
+ this.control.detach();
2653
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.remove(this.helperObject);
2654
+ }
2655
+ refresh() {
2656
+ var _a, _b, _c;
2657
+ if (!this.primaryTarget) {
2658
+ return;
2659
+ }
2660
+ this.control.detach();
2661
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.remove(this.helperObject);
2662
+ this.targetMatrixMap.clear();
2663
+ let tMatrix = this.primaryTarget.getMatrixInWorld();
2664
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2665
+ (_b = this.controller.world.scene) === null || _b === void 0 ? void 0 : _b.add(this.control.getHelper());
2666
+ (_c = this.controller.world.scene) === null || _c === void 0 ? void 0 : _c.add(this.helperObject);
2667
+ this.control.attach(this.helperObject);
2668
+ this.targets.forEach((elem) => {
2669
+ const tarMatrix = elem.getMatrixInWorld();
2670
+ const TB_local = tMatrix.clone().invert().multiply(tarMatrix);
2671
+ this.targetMatrixMap.set(elem, TB_local);
2672
+ });
2673
+ }
2674
+ onChange() {
2675
+ this.controller.viewPort.markRenderStateDirty();
2676
+ }
2677
+ onDraggingChanged(event) {
2678
+ if (this.primaryTarget) {
2679
+ let tMatrix = this.primaryTarget.getMatrixInWorld();
2680
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2681
+ }
2682
+ this.onDraggingFunctions.forEach((elem) => {
2683
+ elem(event.value);
2684
+ });
2685
+ }
2686
+ onObjectChanged() {
2687
+ if (this.primaryTarget) {
2688
+ //const TA1 = this.primaryTarget.getMatrixInWorld();
2689
+ this.helperObject.updateMatrixWorld(true);
2690
+ const TA2 = this.helperObject.matrixWorld.clone();
2691
+ this.primaryTarget.onTransforming(TA2);
2692
+ // const TA1Inverse = TA1.clone().invert();
2693
+ //const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
2694
+ this.targets.forEach((tar) => {
2695
+ if (tar !== this.primaryTarget) {
2696
+ let t = this.targetMatrixMap.get(tar);
2697
+ if (t) {
2698
+ let TB2 = new three.Matrix4().multiplyMatrices(TA2, t); // B
2699
+ tar.onTransforming(TB2);
2700
+ }
2701
+ }
2702
+ });
2703
+ }
2704
+ this.onUpdateFunctions.forEach((elem) => {
2705
+ elem();
2706
+ });
2707
+ }
2708
+ set enable(newEnable) {
2709
+ this.control.enabled = newEnable;
2710
+ }
2711
+ setTarget(primaryTarget, multiTargets, onUpdate = null, onDragging = null) {
2712
+ var _a;
2713
+ this.targetMatrixMap.clear();
2714
+ let tMatrix = primaryTarget.getMatrixInWorld();
2715
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2716
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.add(this.control.getHelper());
2717
+ // this.control.attach(this.helperObject);
2718
+ this.primaryTarget = primaryTarget;
2719
+ this.targets = multiTargets;
2720
+ this.targets.forEach((elem) => {
2721
+ const tarMatrix = elem.getMatrixInWorld();
2722
+ const TB_local = tMatrix.clone().invert().multiply(tarMatrix);
2723
+ this.targetMatrixMap.set(elem, TB_local);
2724
+ });
2725
+ if (onUpdate) {
2726
+ this.onUpdateFunctions.push(onUpdate);
2727
+ }
2728
+ if (onUpdate) {
2729
+ this.onUpdateFunctions.push(onUpdate);
2730
+ }
2731
+ if (onDragging) {
2732
+ this.onDraggingFunctions.push(onDragging);
2733
+ }
2734
+ this.isTickEnabled = true;
2735
+ }
2736
+ getMode() {
2737
+ return this.control.getMode();
2738
+ }
2739
+ setMode(mode) {
2740
+ this.control.setMode(mode);
2741
+ }
2742
+ setSpace(space) {
2743
+ this.control.setSpace(space);
2744
+ }
2745
+ setAxis(axis) {
2746
+ this.control.showX = axis ? axis === null || axis === void 0 ? void 0 : axis.includes("X") : false;
2747
+ this.control.showY = axis ? axis === null || axis === void 0 ? void 0 : axis.includes("Y") : false;
2748
+ this.control.showZ = axis ? axis === null || axis === void 0 ? void 0 : axis.includes("Z") : false;
2749
+ }
2750
+ setSize(size) {
2751
+ this.control.setSize(size);
2752
+ }
2753
+ destroy() {
2754
+ var _a;
2755
+ this.isTickEnabled = false;
2756
+ this.unpossess();
2757
+ this.targetMatrixMap.clear();
2758
+ this.targets = [];
2759
+ this.primaryTarget = null;
2760
+ this.onUpdateFunctions = [];
2761
+ this.onDraggingFunctions = [];
2762
+ (_a = this._control) === null || _a === void 0 ? void 0 : _a.dispose();
2763
+ this._control = null;
2764
+ super.destroy();
2765
+ }
2766
+ }
2767
+
2614
2768
  exports.Actor = Actor;
2615
2769
  exports.BoxActor = BoxActor;
2616
2770
  exports.BoxComponent = BoxComponent;
@@ -2641,6 +2795,7 @@ exports.SceneComponent = SceneComponent;
2641
2795
  exports.SphereComponent = SphereComponent;
2642
2796
  exports.ThreeJsApp = ThreeJsApp;
2643
2797
  exports.ToneMappingOptions = ToneMappingOptions;
2798
+ exports.TransformGizmo = TransformGizmo;
2644
2799
  exports.Viewport = Viewport;
2645
2800
  exports.WebGPUPostProcessFactory = WebGPUPostProcessFactory;
2646
2801
  exports.World = World;
@@ -1,12 +1,11 @@
1
- import { MathUtils, Group, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, BufferGeometry, Material, Texture, LoadingManager, FileLoader, Scene, NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping, Vector2, Raycaster, PerspectiveCamera, OrthographicCamera, Clock, DirectionalLight, MeshStandardMaterial, BoxGeometry, MeshBasicMaterial, PlaneGeometry, SphereGeometry } from 'three';
1
+ import { MathUtils, Group, Vector3, Box3, Quaternion, Euler, Matrix4, Mesh, BufferGeometry, Material, Texture, LoadingManager, FileLoader, Scene, NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping, Vector2, Raycaster, PerspectiveCamera, OrthographicCamera, Clock, DirectionalLight, MeshStandardMaterial, BoxGeometry, MeshBasicMaterial, PlaneGeometry, SphereGeometry, Object3D } from 'three';
2
2
  import { DRACOLoader, GLTFLoader, CSS2DRenderer, OrbitControls } from 'three/examples/jsm/Addons.js';
3
- import { blendColor, uniform as uniform$1, time, oscSine } from 'three/examples/jsm/nodes/Nodes.js';
4
- import { WebGPURenderer, PostProcessing, Color } from 'three/examples/jsm/renderers/webgpu/WebGPURenderer.js';
3
+ import { pass, mrt, output, uniform, velocity, metalness, transformedNormalView, blendColor, time, oscSine } from 'three/tsl';
4
+ import { WebGPURenderer, PostProcessing, Color } from 'three/webgpu';
5
5
  import { bloom } from 'three/examples/jsm/tsl/display/BloomNode.js';
6
6
  import { denoise } from 'three/examples/jsm/tsl/display/DenoiseNode.js';
7
7
  import { dof } from 'three/examples/jsm/tsl/display/DepthOfFieldNode.js';
8
8
  import { ao } from 'three/examples/jsm/tsl/display/GTAONode.js';
9
- import { pass, mrt, output, uniform, velocity, metalness, transformedNormalView } from 'three/tsl';
10
9
  import { ssr } from 'three/examples/jsm/tsl/display/SSRNode.js';
11
10
  import { lensflare } from 'three/examples/jsm/tsl/display/LensflareNode.js';
12
11
  import { outline } from 'three/examples/jsm/tsl/display/OutlineNode.js';
@@ -15,6 +14,7 @@ import { fxaa } from 'three/examples/jsm/tsl/display/FXAANode.js';
15
14
  import { smaa } from 'three/examples/jsm/tsl/display/SMAANode.js';
16
15
  import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
17
16
  import { PointerLockControls } from 'three/examples/jsm/controls/PointerLockControls';
17
+ import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
18
18
 
19
19
  class LYLoadTask {
20
20
  constructor(paths, onLoaded) {
@@ -1472,10 +1472,10 @@ class Viewport {
1472
1472
  WebGPUPostProcessFactory.updateOutlinePass(this.outlinePass, this.outlineObjects, this.postProcessParam.outline);
1473
1473
  }
1474
1474
  const { visibleEdge, hiddenEdge } = this.outlinePass;
1475
- const pulsePeriod = uniform$1(this.postProcessParam.outline.pulsePeriod);
1475
+ const pulsePeriod = uniform(this.postProcessParam.outline.pulsePeriod);
1476
1476
  const period = time.div(pulsePeriod).mul(2);
1477
1477
  const osc = oscSine(period).mul(.5).add(.5);
1478
- const outlineColor = visibleEdge.mul(uniform$1(new Color(this.postProcessParam.outline.visibleEdgeColor))).add(hiddenEdge.mul(uniform$1(new Color(this.postProcessParam.outline.hiddenEdgeColor)))).mul(this.postProcessParam.outline.edgeStrength);
1478
+ const outlineColor = visibleEdge.mul(uniform(new Color(this.postProcessParam.outline.visibleEdgeColor))).add(hiddenEdge.mul(uniform(new Color(this.postProcessParam.outline.hiddenEdgeColor)))).mul(this.postProcessParam.outline.edgeStrength);
1479
1479
  const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
1480
1480
  // if(!this.denoiseOutlinePass)
1481
1481
  // {
@@ -2609,4 +2609,158 @@ class FirstPerson extends Pawn {
2609
2609
  }
2610
2610
  }
2611
2611
 
2612
- export { Actor, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOutlineParams, DefaultPostProcessParam, DefaultRenderParam, DefaultSSRParam, DefaultToneMappingParams, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, LYAssetManager, LYLoadTask, LabelComponent, MeshComponent, Orbital, PlaneActor, PlaneComponent, SceneComponent, SphereComponent, ThreeJsApp, ToneMappingOptions, Viewport, WebGPUPostProcessFactory, World };
2612
+ class TransformGizmo extends Pawn {
2613
+ get control() {
2614
+ if (!this._control) {
2615
+ throw new Error("Control not initialized");
2616
+ }
2617
+ return this._control;
2618
+ }
2619
+ constructor(controller) {
2620
+ super(controller);
2621
+ this._control = null;
2622
+ this.helperObject = new Object3D();
2623
+ this.targets = [];
2624
+ this.primaryTarget = null;
2625
+ this.targetMatrixMap = new Map();
2626
+ this.onDraggingChangedEvent = (param) => { this.onDraggingChanged(param); };
2627
+ this.onObjectChangeEvent = () => { this.onObjectChanged(); };
2628
+ this.onChangeEvent = () => { this.onChange(); };
2629
+ this.onUpdateFunctions = [];
2630
+ this.onDraggingFunctions = [];
2631
+ this._control = new TransformControls(controller.camera, controller.viewPort.canvas);
2632
+ this.control.getHelper().traverse((elem) => {
2633
+ elem.userData["rayIgnored"] = true;
2634
+ });
2635
+ this.helperObject.name = "TransformHelperObject";
2636
+ }
2637
+ possess() {
2638
+ var _a;
2639
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.add(this.helperObject);
2640
+ this.control.attach(this.helperObject);
2641
+ this.control.addEventListener('change', this.onChangeEvent);
2642
+ this.control.addEventListener('dragging-changed', this.onDraggingChangedEvent);
2643
+ this.control.addEventListener('objectChange', this.onObjectChangeEvent);
2644
+ }
2645
+ unpossess() {
2646
+ var _a;
2647
+ this.control.removeEventListener('change', this.onChangeEvent);
2648
+ this.control.removeEventListener('dragging-changed', this.onDraggingChangedEvent);
2649
+ this.control.removeEventListener('objectChange', this.onObjectChangeEvent);
2650
+ this.control.detach();
2651
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.remove(this.helperObject);
2652
+ }
2653
+ refresh() {
2654
+ var _a, _b, _c;
2655
+ if (!this.primaryTarget) {
2656
+ return;
2657
+ }
2658
+ this.control.detach();
2659
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.remove(this.helperObject);
2660
+ this.targetMatrixMap.clear();
2661
+ let tMatrix = this.primaryTarget.getMatrixInWorld();
2662
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2663
+ (_b = this.controller.world.scene) === null || _b === void 0 ? void 0 : _b.add(this.control.getHelper());
2664
+ (_c = this.controller.world.scene) === null || _c === void 0 ? void 0 : _c.add(this.helperObject);
2665
+ this.control.attach(this.helperObject);
2666
+ this.targets.forEach((elem) => {
2667
+ const tarMatrix = elem.getMatrixInWorld();
2668
+ const TB_local = tMatrix.clone().invert().multiply(tarMatrix);
2669
+ this.targetMatrixMap.set(elem, TB_local);
2670
+ });
2671
+ }
2672
+ onChange() {
2673
+ this.controller.viewPort.markRenderStateDirty();
2674
+ }
2675
+ onDraggingChanged(event) {
2676
+ if (this.primaryTarget) {
2677
+ let tMatrix = this.primaryTarget.getMatrixInWorld();
2678
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2679
+ }
2680
+ this.onDraggingFunctions.forEach((elem) => {
2681
+ elem(event.value);
2682
+ });
2683
+ }
2684
+ onObjectChanged() {
2685
+ if (this.primaryTarget) {
2686
+ //const TA1 = this.primaryTarget.getMatrixInWorld();
2687
+ this.helperObject.updateMatrixWorld(true);
2688
+ const TA2 = this.helperObject.matrixWorld.clone();
2689
+ this.primaryTarget.onTransforming(TA2);
2690
+ // const TA1Inverse = TA1.clone().invert();
2691
+ //const transformMatrix = new Matrix4().multiplyMatrices(TA2, TA1Inverse);
2692
+ this.targets.forEach((tar) => {
2693
+ if (tar !== this.primaryTarget) {
2694
+ let t = this.targetMatrixMap.get(tar);
2695
+ if (t) {
2696
+ let TB2 = new Matrix4().multiplyMatrices(TA2, t); // B
2697
+ tar.onTransforming(TB2);
2698
+ }
2699
+ }
2700
+ });
2701
+ }
2702
+ this.onUpdateFunctions.forEach((elem) => {
2703
+ elem();
2704
+ });
2705
+ }
2706
+ set enable(newEnable) {
2707
+ this.control.enabled = newEnable;
2708
+ }
2709
+ setTarget(primaryTarget, multiTargets, onUpdate = null, onDragging = null) {
2710
+ var _a;
2711
+ this.targetMatrixMap.clear();
2712
+ let tMatrix = primaryTarget.getMatrixInWorld();
2713
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2714
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.add(this.control.getHelper());
2715
+ // this.control.attach(this.helperObject);
2716
+ this.primaryTarget = primaryTarget;
2717
+ this.targets = multiTargets;
2718
+ this.targets.forEach((elem) => {
2719
+ const tarMatrix = elem.getMatrixInWorld();
2720
+ const TB_local = tMatrix.clone().invert().multiply(tarMatrix);
2721
+ this.targetMatrixMap.set(elem, TB_local);
2722
+ });
2723
+ if (onUpdate) {
2724
+ this.onUpdateFunctions.push(onUpdate);
2725
+ }
2726
+ if (onUpdate) {
2727
+ this.onUpdateFunctions.push(onUpdate);
2728
+ }
2729
+ if (onDragging) {
2730
+ this.onDraggingFunctions.push(onDragging);
2731
+ }
2732
+ this.isTickEnabled = true;
2733
+ }
2734
+ getMode() {
2735
+ return this.control.getMode();
2736
+ }
2737
+ setMode(mode) {
2738
+ this.control.setMode(mode);
2739
+ }
2740
+ setSpace(space) {
2741
+ this.control.setSpace(space);
2742
+ }
2743
+ setAxis(axis) {
2744
+ this.control.showX = axis ? axis === null || axis === void 0 ? void 0 : axis.includes("X") : false;
2745
+ this.control.showY = axis ? axis === null || axis === void 0 ? void 0 : axis.includes("Y") : false;
2746
+ this.control.showZ = axis ? axis === null || axis === void 0 ? void 0 : axis.includes("Z") : false;
2747
+ }
2748
+ setSize(size) {
2749
+ this.control.setSize(size);
2750
+ }
2751
+ destroy() {
2752
+ var _a;
2753
+ this.isTickEnabled = false;
2754
+ this.unpossess();
2755
+ this.targetMatrixMap.clear();
2756
+ this.targets = [];
2757
+ this.primaryTarget = null;
2758
+ this.onUpdateFunctions = [];
2759
+ this.onDraggingFunctions = [];
2760
+ (_a = this._control) === null || _a === void 0 ? void 0 : _a.dispose();
2761
+ this._control = null;
2762
+ super.destroy();
2763
+ }
2764
+ }
2765
+
2766
+ export { Actor, AttachmentRules, BoxActor, BoxComponent, Controller, DefaultAppParam, DefaultBloomParam, DefaultCameraParam, DefaultDOFParam, DefaultDenoiseParam, DefaultGTAOParam, DefaultOutlineParams, DefaultPostProcessParam, DefaultRenderParam, DefaultSSRParam, DefaultToneMappingParams, Delegate, DirectionalLightActor, DirectionalLightComponent, FirstPerson, LYAssetManager, LYLoadTask, LabelComponent, MeshComponent, Orbital, PlaneActor, PlaneComponent, SceneComponent, SphereComponent, ThreeJsApp, ToneMappingOptions, TransformGizmo, Viewport, WebGPUPostProcessFactory, World };
package/dist/index.d.ts CHANGED
@@ -38,3 +38,5 @@ export { LabelComponent } from "./lythreeframe/Object/Components/2D/2DComponent"
38
38
  export { Orbital } from "./lythreeframe/Object/PawnV2/Oribital";
39
39
  export { FirstPerson } from "./lythreeframe/Object/PawnV2/FirstPerson";
40
40
  export type { ITransforming } from "./lythreeframe/Object/PawnV2/TransformControl";
41
+ export { TransformType } from "./lythreeframe/Object/PawnV2/TransformControl";
42
+ export { TransformGizmo } from "./lythreeframe/Object/PawnV2/TransformControl";
@@ -1,6 +1,6 @@
1
1
  import { PostProcessParam } from './../PostProcess/PostProcessParam';
2
2
  import { WebGPURendererParameters } from "three/src/renderers/webgpu/WebGPURenderer.js";
3
- import { WebGPURenderer } from "three/examples/jsm/renderers/webgpu/WebGPURenderer.js";
3
+ import { WebGPURenderer } from "three/webgpu";
4
4
  import { BloomParam } from "../PostProcess/Param/Bloom";
5
5
  import { GTAOParam } from "../PostProcess/Param/GTAO";
6
6
  import { ToneMappingParams } from "../PostProcess/Param/ToneMapping";
@@ -30,11 +30,12 @@ export declare class TransformGizmo extends Pawn {
30
30
  constructor(controller: Controller);
31
31
  possess(): void;
32
32
  unpossess(): void;
33
- onChange(): void;
34
- onDraggingChanged(event: {
33
+ refresh(): void;
34
+ protected onChange(): void;
35
+ protected onDraggingChanged(event: {
35
36
  value: any;
36
37
  }): void;
37
- onObjectChanged(): void;
38
+ protected onObjectChanged(): void;
38
39
  set enable(newEnable: boolean);
39
40
  setTarget(primaryTarget: ITransforming, multiTargets: ITransforming[], onUpdate?: (() => void) | null, onDragging?: ((bDragging: boolean) => void) | null): void;
40
41
  getMode(): "translate" | "rotate" | "scale";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lythreeframe",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",