@needle-tools/materialx 1.0.0-next.2fb4497 → 1.0.0-next.5e016a7

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.
@@ -0,0 +1,36 @@
1
+ name: Release Workflow
2
+ on:
3
+ push:
4
+ branches:
5
+ - 'release/stable'
6
+ - 'release/next'
7
+ - 'release/experimental'
8
+
9
+ jobs:
10
+ run-release-script:
11
+ runs-on: ubuntu-latest
12
+ timeout-minutes: 5
13
+ defaults:
14
+ run:
15
+ working-directory: ./
16
+ steps:
17
+ - name: Checkout code
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: '22'
24
+
25
+ - name: Install dependencies
26
+ run: npm ci
27
+
28
+ - name: Publish to npm (stable branch)
29
+ if: startsWith(github.ref_name, 'release/stable')
30
+ run: npx --yes needle-publish-helper@stable publish "." --webhook "${{ secrets.DISCORD_WEBHOOK }}" --access-token "${{ secrets.NPM_TOKEN }}" --tag "stable" --create-tag "release/"
31
+
32
+ - name: Publish to npm (next and experimental branches)
33
+ if: ${{ !startsWith(github.ref_name, 'release/stable') }}
34
+ run: npx --yes needle-publish-helper@stable publish "." --webhook "${{ secrets.DISCORD_WEBHOOK }}" --access-token "${{ secrets.NPM_TOKEN }}" --tag "${{ github.ref_name }}" --version+tag --version+hash --create-tag "release/"
35
+
36
+
package/bin/README.md ADDED
@@ -0,0 +1,5 @@
1
+ Source: https://github.com/AcademySoftwareFoundation/MaterialX/tree/gh-pages
2
+
3
+ Edits:
4
+
5
+ - `JsMaterialXGenShader.js` added `export default MaterialX;` at bottom
package/package.json CHANGED
@@ -1,24 +1,17 @@
1
1
  {
2
2
  "name": "@needle-tools/materialx",
3
- "version": "1.0.0-next.2fb4497",
3
+ "version": "1.0.0-next.5e016a7",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
- "exports": {
7
- ".": {
8
- "import": "./index.ts",
9
- "require": "./index.js"
10
- },
11
- "./package.json": "./package.json"
12
- },
6
+ "dependencies": {},
13
7
  "peerDependencies": {
14
8
  "@needle-tools/engine": "4.x",
15
9
  "three": "npm:@needle-tools/three@^0.169.5"
16
10
  },
17
11
  "devDependencies": {
18
12
  "@needle-tools/engine": "4.x",
19
- "@types/three": "0.169.0",
20
13
  "three": "npm:@needle-tools/three@^0.169.5",
21
- "vite": "^7.0.3"
14
+ "@types/three": "0.169.0"
22
15
  },
23
16
  "publishConfig": {
24
17
  "access": "public",
package/src/materialx.ts CHANGED
@@ -5,6 +5,24 @@ import { renderPMREMToEquirect } from "./textureHelper.js";
5
5
  import { Light, MeshBasicMaterial, Object3D, PMREMGenerator } from "three";
6
6
  import { registerLights } from "./helper.js";
7
7
 
8
+ // Configure MaterialX with the correct path for its data files
9
+ const materialXConfig = {
10
+ locateFile: (path: string, scriptDirectory: string) => {
11
+ if (debug) console.debug("MaterialX locateFile called:", { path, scriptDirectory });
12
+
13
+ // Return the correct path for MaterialX data files
14
+ if (path.endsWith('.data') || path.endsWith('.wasm')) {
15
+ // For Vite dev server, we need to use the correct module path
16
+ const correctPath = new URL(`../bin/${path}`, import.meta.url).href;
17
+ if (debug) console.log("Resolved path:", correctPath);
18
+ return correctPath;
19
+ }
20
+ return scriptDirectory + path;
21
+ },
22
+ // Add buffer allocation to handle the data file properly
23
+ wasmBinary: null,
24
+ wasmMemory: null
25
+ };
8
26
 
9
27
  // Global MaterialX module instance - initialized lazily
10
28
  export const state = new class {
@@ -22,6 +40,7 @@ export const state = new class {
22
40
  }
23
41
  }
24
42
 
43
+
25
44
  // Initialize MaterialX WASM module lazily
26
45
  export async function initializeMaterialX(): Promise<void> {
27
46
  if (state.materialXInitPromise) {
@@ -31,34 +50,7 @@ export async function initializeMaterialX(): Promise<void> {
31
50
  if (state.materialXModule) return; // Already initialized
32
51
  if (debug) console.log("Initializing MaterialX WASM module...");
33
52
  try {
34
-
35
- const urls = await Promise.all([
36
- /** @ts-ignore */
37
- import(`../bin/JsMaterialXCore.wasm?url`),
38
- /** @ts-ignore */
39
- import(`../bin/JsMaterialXGenShader.wasm?url`),
40
- /** @ts-ignore */
41
- import(`../bin/JsMaterialXGenShader.data?url`),
42
- ]);
43
- const [JsMaterialXCore, JsMaterialXGenShader, JsMaterialXGenShader_data] = urls;
44
-
45
- const module = await MaterialX({
46
- locateFile: (path: string, scriptDirectory: string) => {
47
- if (debug) console.debug("MaterialX locateFile called:", { path, scriptDirectory });
48
-
49
- if (path.includes("JsMaterialXCore.wasm")) {
50
- return JsMaterialXCore; // Use the URL for the core WASM file
51
- }
52
- else if (path.includes("JsMaterialXGenShader.wasm")) {
53
- return JsMaterialXGenShader; // Use the URL for the shader WASM file
54
- }
55
- else if (path.includes("JsMaterialXGenShader.data")) {
56
- return JsMaterialXGenShader_data; // Use the URL for the shader data file
57
- }
58
-
59
- return scriptDirectory + path;
60
- },
61
- });
53
+ const module = await MaterialX(materialXConfig);
62
54
  if (debug) console.log("MaterialXLoader module loaded", module);
63
55
  state.materialXModule = module;
64
56
 
@@ -0,0 +1,18 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": "."
5
+ },
6
+ {
7
+ "name": "Needle",
8
+ "path": "./node_modules/@needle-tools"
9
+ }
10
+ ],
11
+ "settings": {
12
+ "files.exclude": {
13
+ "**/.git": true,
14
+ "**/.DS_Store": true,
15
+ "**/*.meta": true
16
+ }
17
+ }
18
+ }