@needle-tools/usd 0.0.1-alpha → 0.0.1-alpha.2
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/CHANGELOG.md +8 -0
- package/README.md +14 -2
- package/package.json +5 -1
- package/src/index.d.ts +5 -1
- package/src/plugins/needle.js +12 -12
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this package will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.0.1-alpha.1] - 2025-05-14
|
|
8
|
+
- initial release
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Needle USD
|
|
2
2
|
|
|
3
|
-
USD wasm runtime and three.js hydra delegate
|
|
3
|
+
USD wasm runtime and three.js hydra delegate.
|
|
4
|
+
Developed & maintained by [Needle](https://needle.tools)
|
|
5
|
+
For commercial use please contact hi@needle.tools
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
`npm install @needle-tools/usd`
|
|
@@ -68,4 +70,14 @@ driver.Draw();
|
|
|
68
70
|
|
|
69
71
|
Uses Asyncify to handle async calls in emscripten.
|
|
70
72
|
> A synchronous call in C that waits for an asynchronous operation in JS to complete.
|
|
71
|
-
https://emscripten.org/docs/porting/asyncify.html
|
|
73
|
+
https://emscripten.org/docs/porting/asyncify.html
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# Contact ✒️
|
|
77
|
+
<b>[🌵 Needle](https://needle.tools)</b> •
|
|
78
|
+
[Github](https://github.com/needle-tools) •
|
|
79
|
+
[Twitter](https://twitter.com/NeedleTools) •
|
|
80
|
+
[Discord](https://discord.needle.tools) •
|
|
81
|
+
[Forum](https://forum.needle.tools) •
|
|
82
|
+
[Youtube](https://www.youtube.com/@needle-tools)
|
|
83
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/usd",
|
|
3
|
-
"version": "0.0.1-alpha",
|
|
3
|
+
"version": "0.0.1-alpha.2",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./src/index.js",
|
|
10
10
|
"require": "./src/index.cjs"
|
|
11
|
+
},
|
|
12
|
+
"./plugins": {
|
|
13
|
+
"import": "./src/plugins/index.js",
|
|
14
|
+
"require": "./src/plugins/index.cjs"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"keywords": [
|
package/src/index.d.ts
CHANGED
package/src/plugins/needle.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { Loader, Object3D } from "three";
|
|
2
2
|
import { createThreeHydra, getUsdModule } from "../index.js";
|
|
3
|
-
import { addComponent, Behaviour, NeedleEngineModelLoader } from "@needle-tools/engine";
|
|
4
|
-
|
|
5
3
|
|
|
6
4
|
|
|
7
5
|
/** @type {import("../types").addPluginForNeedleEngine} */
|
|
8
6
|
export async function addPluginForNeedleEngine(options) {
|
|
9
|
-
console.debug("🐉 Adding USDZ plugin to Needle Engine");
|
|
10
|
-
return
|
|
7
|
+
if (options.debug) console.debug("🐉 Adding USDZ plugin to Needle Engine");
|
|
8
|
+
return import("@needle-tools/engine").then(module => {
|
|
9
|
+
return onAddNeedlePlugin(module, options);
|
|
10
|
+
})
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
+
* @param {typeof import("@needle-tools/engine")} NEEDLE
|
|
15
16
|
* @param {import("../types").PluginContext} opts
|
|
16
17
|
*/
|
|
17
|
-
function onAddNeedlePlugin(opts) {
|
|
18
|
+
function onAddNeedlePlugin(NEEDLE, opts) {
|
|
18
19
|
|
|
19
|
-
class NeedleUSDZHHandler extends Behaviour {
|
|
20
|
+
class NeedleUSDZHHandler extends NEEDLE.Behaviour {
|
|
20
21
|
constructor() {
|
|
21
22
|
super();
|
|
22
23
|
/**
|
|
@@ -24,7 +25,6 @@ function onAddNeedlePlugin(opts) {
|
|
|
24
25
|
*/
|
|
25
26
|
this.handle = null;
|
|
26
27
|
this.root = new Object3D();
|
|
27
|
-
console.debug("Create root", this.root);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
update() {
|
|
@@ -81,7 +81,7 @@ function onAddNeedlePlugin(opts) {
|
|
|
81
81
|
debug
|
|
82
82
|
// setURLModifier: USDLoadingManager.urlModifier,
|
|
83
83
|
}).then(res => {
|
|
84
|
-
console.debug("🐉 USD HYDRA IS READY");
|
|
84
|
+
if (debug) console.debug("🐉 USD HYDRA IS READY");
|
|
85
85
|
return res;
|
|
86
86
|
})
|
|
87
87
|
const usd = await NeedleUSDZLoader.usdModule;
|
|
@@ -98,7 +98,7 @@ function onAddNeedlePlugin(opts) {
|
|
|
98
98
|
});
|
|
99
99
|
this.comp.handle = handle;
|
|
100
100
|
|
|
101
|
-
console.debug("Loaded", this.comp);
|
|
101
|
+
if (debug) console.debug("Loaded", this.comp);
|
|
102
102
|
|
|
103
103
|
onProgress?.(new ProgressEvent("load", { lengthComputable: true, loaded: 1, total: 1 }));
|
|
104
104
|
|
|
@@ -115,7 +115,7 @@ function onAddNeedlePlugin(opts) {
|
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
const removeFiletype = NeedleEngineModelLoader.onDetermineModelMimetype(cb => {
|
|
118
|
+
const removeFiletype = NEEDLE.NeedleEngineModelLoader.onDetermineModelMimetype(cb => {
|
|
119
119
|
|
|
120
120
|
if (cb.contentType === "application/vnd.usd") {
|
|
121
121
|
return "model/vnd.usd";
|
|
@@ -135,11 +135,11 @@ function onAddNeedlePlugin(opts) {
|
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
const handlers = new Array();
|
|
138
|
-
const removeCustomLoader = NeedleEngineModelLoader.onCreateCustomModelLoader(cb => {
|
|
138
|
+
const removeCustomLoader = NEEDLE.NeedleEngineModelLoader.onCreateCustomModelLoader(cb => {
|
|
139
139
|
if (cb.mimetype.startsWith("model/vnd.usd")) {
|
|
140
140
|
const handler = new NeedleUSDZHHandler();
|
|
141
141
|
handlers.push(handler);
|
|
142
|
-
addComponent(cb.context.scene, handler);
|
|
142
|
+
NEEDLE.addComponent(cb.context.scene, handler);
|
|
143
143
|
return new NeedleUSDZLoader(handler);
|
|
144
144
|
}
|
|
145
145
|
return null;
|