three-zoo 0.12.1 → 0.13.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { AimChainIK } from "./IK/AimChainIK";
2
- export { TwoBoneIK } from "./IK/TwoBoneIK";
1
+ export { AimChainIK } from "./ik/AimChainIK";
2
+ export { TwoBoneIK } from "./ik/TwoBoneIK";
3
3
  export { InstancedMeshGroup } from "./instancedMeshPool/InstancedMeshGroup";
4
4
  export { InstancedMeshInstance } from "./instancedMeshPool/InstancedMeshInstance";
5
5
  export { InstancedMeshPool } from "./instancedMeshPool/InstancedMeshPool";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { AimChainIK } from './IK/AimChainIK.js';
2
- export { TwoBoneIK } from './IK/TwoBoneIK.js';
1
+ export { AimChainIK } from './ik/AimChainIK.js';
2
+ export { TwoBoneIK } from './ik/TwoBoneIK.js';
3
3
  export { InstancedMeshGroup } from './instancedMeshPool/InstancedMeshGroup.js';
4
4
  export { InstancedMeshInstance } from './instancedMeshPool/InstancedMeshInstance.js';
5
5
  export { InstancedMeshPool } from './instancedMeshPool/InstancedMeshPool.js';
@@ -1,4 +1,4 @@
1
- import type { BufferGeometry, Material } from "three";
1
+ import type { BufferGeometry, InstancedMesh, Material } from "three";
2
2
  import { Matrix4, Quaternion, Vector3 } from "three";
3
3
  import type { InstancedMeshPool } from "./InstancedMeshPool";
4
4
  export declare class InstancedMeshInstance {
@@ -12,6 +12,7 @@ export declare class InstancedMeshInstance {
12
12
  private needsUpdateInstancedMatrixFromLocalMatrix;
13
13
  private handler;
14
14
  constructor(pool: InstancedMeshPool, geometry: BufferGeometry, material: Material, tag?: string);
15
+ static fromInstancedMesh(pool: InstancedMeshPool, mesh: InstancedMesh<BufferGeometry, Material>, tag?: string): InstancedMeshInstance[];
15
16
  destroy(): void;
16
17
  isDestroyed(): boolean;
17
18
  setPosition(source: Vector3, flushTransform?: boolean): this;
@@ -12,6 +12,17 @@ class InstancedMeshInstance {
12
12
  this._private_needsUpdateInstancedMatrixFromLocalMatrix = false;
13
13
  this._private_handler = this._private_pool.allocate(geometry, material, tag);
14
14
  }
15
+ static fromInstancedMesh(pool, mesh, tag = "") {
16
+ const matrix = new Matrix4();
17
+ const instances = [];
18
+ for (let i = 0; i < mesh.count; i++) {
19
+ const instance = new InstancedMeshInstance(pool, mesh.geometry, mesh.material, tag);
20
+ mesh.getMatrixAt(i, matrix);
21
+ instance.setTransform(matrix, true);
22
+ instances.push(instance);
23
+ }
24
+ return instances;
25
+ }
15
26
  destroy() {
16
27
  if (this._private_handler >= 0) {
17
28
  this._private_pool.deallocate(this._private_handler);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-zoo",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "Some reusable bits for building things with Three.js",
5
5
  "keywords": [
6
6
  "three.js",
File without changes
File without changes
File without changes
File without changes