@s0rt/3dvf 0.2.1 → 0.3.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/cli/index.js +6 -2
- package/dist/cli/templates/create/vite.config.ts +16 -1
- package/package.json +1 -1
- package/readme.md +55 -0
package/dist/cli/index.js
CHANGED
|
@@ -3608,7 +3608,7 @@ var package_default;
|
|
|
3608
3608
|
var init_package = __esm(() => {
|
|
3609
3609
|
package_default = {
|
|
3610
3610
|
name: "@s0rt/3dvf",
|
|
3611
|
-
version: "0.
|
|
3611
|
+
version: "0.3.0",
|
|
3612
3612
|
description: "shadcn-style Three.js function library CLI",
|
|
3613
3613
|
type: "module",
|
|
3614
3614
|
bin: {
|
|
@@ -10035,7 +10035,11 @@ function writeRegistryItem(item, outputDir, version, cwd = process.cwd()) {
|
|
|
10035
10035
|
for (const file of item.files) {
|
|
10036
10036
|
const dest = join2(itemDir, file.path);
|
|
10037
10037
|
mkdirSync(dirname(dest), { recursive: true });
|
|
10038
|
-
|
|
10038
|
+
if (file.encoding === "base64") {
|
|
10039
|
+
writeFileSync2(dest, Buffer.from(file.content, "base64"));
|
|
10040
|
+
} else {
|
|
10041
|
+
writeFileSync2(dest, file.content, "utf-8");
|
|
10042
|
+
}
|
|
10039
10043
|
written.push(dest);
|
|
10040
10044
|
}
|
|
10041
10045
|
const stampPath = join2(itemDir, VERSION_STAMP_FILE);
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
1
|
+
import { defineConfig, type Plugin } from "vite";
|
|
2
2
|
|
|
3
3
|
import { join, dirname } from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
|
|
6
|
+
import { readFileSync } from "fs";
|
|
7
|
+
|
|
6
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
9
|
const __dirname = dirname(__filename);
|
|
8
10
|
|
|
11
|
+
function glslPlugin(): Plugin {
|
|
12
|
+
return {
|
|
13
|
+
name: "glsl-raw",
|
|
14
|
+
load(id) {
|
|
15
|
+
if (id.endsWith(".glsl")) {
|
|
16
|
+
const source = readFileSync(id, "utf-8");
|
|
17
|
+
return `export default ${JSON.stringify(source)};`;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
export default defineConfig({
|
|
24
|
+
plugins: [glslPlugin()],
|
|
10
25
|
resolve: {
|
|
11
26
|
alias: {
|
|
12
27
|
"@3dvf": join(__dirname, "./__OUTPUT_DIR__"),
|
package/package.json
CHANGED
package/readme.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
## dev
|
|
2
|
+
|
|
3
|
+
### link local cli
|
|
4
|
+
|
|
5
|
+
`bun link`
|
|
6
|
+
|
|
7
|
+
### run the cli
|
|
8
|
+
|
|
9
|
+
`bun run dev`
|
|
10
|
+
|
|
11
|
+
### run the registry
|
|
12
|
+
|
|
13
|
+
`bun run dev:registry`
|
|
14
|
+
|
|
15
|
+
Using `bunx 3dvf <command>` will now use the local cli.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## troubleshotting
|
|
19
|
+
|
|
20
|
+
### .glsl & vite
|
|
21
|
+
|
|
22
|
+
Using the `create` command will already apply this fix.
|
|
23
|
+
|
|
24
|
+
By default vite won't import .glsl files as we want it to, resulting in parsing errors.
|
|
25
|
+
|
|
26
|
+
You can either prepend import path with `?raw`, or, to avoid touching the 3dvf files, use the following plugin :
|
|
27
|
+
|
|
28
|
+
```vite.config.ts
|
|
29
|
+
function glslPlugin(): Plugin {
|
|
30
|
+
return {
|
|
31
|
+
name: 'glsl-raw',
|
|
32
|
+
load(id) {
|
|
33
|
+
if (id.endsWith('.glsl')) {
|
|
34
|
+
const source = readFileSync(id, 'utf-8');
|
|
35
|
+
return `export default ${JSON.stringify(source)};`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
And add it
|
|
43
|
+
```vite.config.ts
|
|
44
|
+
{
|
|
45
|
+
plugins: [glslPlugin]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### .dds
|
|
50
|
+
|
|
51
|
+
```vite.config.ts
|
|
52
|
+
{
|
|
53
|
+
assetsInclude: ['**/*.dds']
|
|
54
|
+
}
|
|
55
|
+
```
|