lythreeframe 1.0.7 → 1.0.9

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.
@@ -1002,6 +1002,9 @@ class LYAssetManager {
1002
1002
  });
1003
1003
  });
1004
1004
  }
1005
+ loadGltfFromBuffer(data, onLoadFinished) {
1006
+ this.gltfLoader.parse(data, window.location.href, onLoadFinished);
1007
+ }
1005
1008
  loadFile(filepath = '', onLoadFinished) {
1006
1009
  const loader = new three.FileLoader();
1007
1010
  loader.load(filepath, (data) => {
@@ -2652,6 +2655,25 @@ class TransformGizmo extends Pawn {
2652
2655
  this.control.detach();
2653
2656
  (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.remove(this.helperObject);
2654
2657
  }
2658
+ refresh() {
2659
+ var _a, _b, _c;
2660
+ if (!this.primaryTarget) {
2661
+ return;
2662
+ }
2663
+ this.control.detach();
2664
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.remove(this.helperObject);
2665
+ this.targetMatrixMap.clear();
2666
+ let tMatrix = this.primaryTarget.getMatrixInWorld();
2667
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2668
+ (_b = this.controller.world.scene) === null || _b === void 0 ? void 0 : _b.add(this.control.getHelper());
2669
+ (_c = this.controller.world.scene) === null || _c === void 0 ? void 0 : _c.add(this.helperObject);
2670
+ this.control.attach(this.helperObject);
2671
+ this.targets.forEach((elem) => {
2672
+ const tarMatrix = elem.getMatrixInWorld();
2673
+ const TB_local = tMatrix.clone().invert().multiply(tarMatrix);
2674
+ this.targetMatrixMap.set(elem, TB_local);
2675
+ });
2676
+ }
2655
2677
  onChange() {
2656
2678
  this.controller.viewPort.markRenderStateDirty();
2657
2679
  }
@@ -1000,6 +1000,9 @@ class LYAssetManager {
1000
1000
  });
1001
1001
  });
1002
1002
  }
1003
+ loadGltfFromBuffer(data, onLoadFinished) {
1004
+ this.gltfLoader.parse(data, window.location.href, onLoadFinished);
1005
+ }
1003
1006
  loadFile(filepath = '', onLoadFinished) {
1004
1007
  const loader = new FileLoader();
1005
1008
  loader.load(filepath, (data) => {
@@ -2650,6 +2653,25 @@ class TransformGizmo extends Pawn {
2650
2653
  this.control.detach();
2651
2654
  (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.remove(this.helperObject);
2652
2655
  }
2656
+ refresh() {
2657
+ var _a, _b, _c;
2658
+ if (!this.primaryTarget) {
2659
+ return;
2660
+ }
2661
+ this.control.detach();
2662
+ (_a = this.controller.world.scene) === null || _a === void 0 ? void 0 : _a.remove(this.helperObject);
2663
+ this.targetMatrixMap.clear();
2664
+ let tMatrix = this.primaryTarget.getMatrixInWorld();
2665
+ tMatrix.decompose(this.helperObject.position, this.helperObject.quaternion, this.helperObject.scale);
2666
+ (_b = this.controller.world.scene) === null || _b === void 0 ? void 0 : _b.add(this.control.getHelper());
2667
+ (_c = this.controller.world.scene) === null || _c === void 0 ? void 0 : _c.add(this.helperObject);
2668
+ this.control.attach(this.helperObject);
2669
+ this.targets.forEach((elem) => {
2670
+ const tarMatrix = elem.getMatrixInWorld();
2671
+ const TB_local = tMatrix.clone().invert().multiply(tarMatrix);
2672
+ this.targetMatrixMap.set(elem, TB_local);
2673
+ });
2674
+ }
2653
2675
  onChange() {
2654
2676
  this.controller.viewPort.markRenderStateDirty();
2655
2677
  }
@@ -2,7 +2,7 @@ import { BufferGeometry, LoadingManager, Material, Mesh, Texture } from 'three';
2
2
  import { SceneComponent } from "../Object/Components/SceneComponent";
3
3
  import { LYLoadTask } from "./Task/Task";
4
4
  import { TAssetPointer } from "./AssetPointer/AssetPointer";
5
- import { DRACOLoader, GLTFLoader } from 'three/examples/jsm/Addons.js';
5
+ import { DRACOLoader, GLTF, GLTFLoader } from 'three/examples/jsm/Addons.js';
6
6
  export declare class LYAssetManager {
7
7
  protected assetPointer: Map<string, TAssetPointer<BufferGeometry | Texture | Material>>;
8
8
  protected readonly dracoLoader: DRACOLoader;
@@ -16,6 +16,7 @@ export declare class LYAssetManager {
16
16
  private collectResourcesAndReferences;
17
17
  checkMeshResource(mesh: Mesh): void;
18
18
  loadMultiGLTFAsGroup(tasks: LYLoadTask[], onProgress?: ((url: string, loaded: number, total: number) => void) | null, onAllFinished?: (() => void) | null): void;
19
+ loadGltfFromBuffer(data: ArrayBuffer | string, onLoadFinished: (gltf: GLTF) => void): void;
19
20
  loadFile(filepath: string | undefined, onLoadFinished: (data: any) => void): void;
20
21
  addAsset(asset: BufferGeometry | Material | Texture, referenceCount?: number): void;
21
22
  releaseAsset(asset: BufferGeometry | Material | Texture): void;
@@ -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.7",
3
+ "version": "1.0.9",
4
4
  "description": "Three.js 封装",
5
5
  "main": "dist/bundle.cjs.js",
6
6
  "module": "dist/bundle.esm.js",