@gamewall/threejs 1.1.0 → 1.2.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/README.md CHANGED
@@ -66,7 +66,7 @@ This function is asynchronous because KTX2 textures may require transcoding, whi
66
66
  > - `--t2` ensures the texture is in KTX2 format
67
67
  > - `--bcmp` applies Basis Universal supercompression
68
68
 
69
- ### `async loadGltf(name: string, renderer: THREE.WebGLRenderer): Promise<[THREE.Object3D, { [name: string]: THREE.MeshPhysicalMaterial }]>`
69
+ ### `async loadGltf(name: string, renderer: THREE.WebGLRenderer): Promise<[THREE.Object3D, { [name: string]: THREE.MeshPhysicalMaterial }, GLTF]>`
70
70
 
71
71
  Loads a GLTF/GLB model from the GameWall assets, with support for KTX2 and Meshopt.
72
72
 
@@ -89,7 +89,13 @@ async function loadModel() {
89
89
  }
90
90
  ```
91
91
 
92
- This function returns a touple containing the loaded model (as a THREE.Object3D) and a dictionary of materials by their names. This allows you to easily modify specific materials after loading.
92
+ This function returns a touple containing
93
+
94
+ - the loaded model (as a THREE.Object3D),
95
+ - a dictionary of materials by their names, and
96
+ - the full GLTF object.
97
+
98
+ This allows you to easily access the 3D object and modify specific materials after loading and access other GLTF data. For advanced use cases, like modifying animations or accessing specific nodes, you can use the GLTF object directly.
93
99
 
94
100
  > ⚠️ Warning: The returned materials dictionary only includes PBR materials (MeshPhysicalMaterial). Please make sure your 3D modeling tool exports materials in this format for compatibility. If you use Blender, the default "Principled BSDF" shader corresponds to MeshPhysicalMaterial in ThreeJS.
95
101
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamewall/threejs",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "ThreeJS utils for GameWall",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
package/src/gltf.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three'
2
- import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'
2
+ import { GLTFLoader, GLTF } from 'three/addons/loaders/GLTFLoader.js'
3
3
  import { getBuffer } from 'gamewall'
4
4
  import { extractBuffer } from './utils'
5
5
 
@@ -19,7 +19,7 @@ export function getGltfLoader(renderer: THREE.WebGLRenderer): GLTFLoader {
19
19
  return loader;
20
20
  }
21
21
 
22
- export async function loadGltf(url: string, renderer: THREE.WebGLRenderer): Promise<[THREE.Object3D, { [name: string]: THREE.MeshPhysicalMaterial }]> {
22
+ export async function loadGltf(url: string, renderer: THREE.WebGLRenderer): Promise<[THREE.Object3D, { [name: string]: THREE.MeshPhysicalMaterial }, GLTF]> {
23
23
  const glbBuffer = extractBuffer(getBuffer(url));
24
24
  const gltfLoader = getGltfLoader(renderer);
25
25
 
@@ -52,5 +52,5 @@ export async function loadGltf(url: string, renderer: THREE.WebGLRenderer): Prom
52
52
  }
53
53
  });
54
54
 
55
- return [result, Object.fromEntries(materials)];
55
+ return [result, Object.fromEntries(materials), gltf];
56
56
  }