@solidrt/3d 0.0.63 → 0.0.65
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/AGENTS.md +338 -48
- package/examples/README.md +3 -3
- package/examples/fog.tsx +18 -5
- package/examples/model-load.tsx +1 -1
- package/package.json +7 -3
- package/src/camera.ts +6 -2
- package/src/components/directional-light.tsx +6 -2
- package/src/components/hemisphere-light.tsx +12 -4
- package/src/components/index.ts +2 -0
- package/src/components/instanced-mesh.tsx +6 -2
- package/src/components/mesh.tsx +12 -1
- package/src/components/point-light.tsx +6 -2
- package/src/components/record-mesh.tsx +14 -2
- package/src/components/scene.tsx +8 -1
- package/src/components/splat-mesh.tsx +50 -0
- package/src/components/spot-light.tsx +7 -3
- package/src/environment.ts +55 -0
- package/src/geometry.ts +1 -1
- package/src/glsl.ts +69 -15
- package/src/gltf.ts +98 -15
- package/src/index.ts +12 -7
- package/src/light.ts +56 -4
- package/src/material.ts +26 -1
- package/src/mesh.ts +361 -6
- package/src/model-data.ts +9 -7
- package/src/model-file.ts +16 -7
- package/src/model.ts +40 -20
- package/src/node.ts +8 -0
- package/src/scene-pointer.ts +6 -5
- package/src/scene-shadows.ts +8 -7
- package/src/scene.ts +225 -104
- package/src/splat-data.ts +617 -0
- package/src/splat.ts +401 -0
- package/tools/model.flux.ts +206 -0
- package/tools/splat.ts +70 -0
- package/tools/model.ts +0 -56
package/tools/model.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
/// <reference path="./node-env.d.ts" />
|
|
3
|
-
|
|
4
|
-
// srt tool 3d/model: bake a glTF into a .srtm model file - the parse
|
|
5
|
-
// (src/gltf.ts) run once here under bun, the result written in the exact
|
|
6
|
-
// layout loadModel views without any per-vertex work at runtime. Same
|
|
7
|
-
// parser, same subset, same result as loadGltf; this only moves the cost
|
|
8
|
-
// to build time. Put the output under assets/ so it ships with the app.
|
|
9
|
-
// Everything here comes from the runtime-free `@solidrt/3d/model` entry
|
|
10
|
-
// (src/model-data.ts), the same surface an app's own bake script uses.
|
|
11
|
-
//
|
|
12
|
-
// srt tool 3d/model <in.gltf|in.glb> [-o <out.srtm>]
|
|
13
|
-
|
|
14
|
-
import { readFileSync, writeFileSync } from "node:fs"
|
|
15
|
-
import { basename, dirname, extname, join } from "node:path"
|
|
16
|
-
import { encodeModel, layoutStride, parseGltf } from "../src/model-data.ts"
|
|
17
|
-
|
|
18
|
-
function usage(error?: string): never {
|
|
19
|
-
if (error) console.error(error)
|
|
20
|
-
console.log("Usage: srt tool 3d/model <in.gltf|in.glb> [-o <out.srtm>]")
|
|
21
|
-
process.exit(error ? 1 : 0)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let input: string | undefined
|
|
25
|
-
let output: string | undefined
|
|
26
|
-
let args = process.argv.slice(2)
|
|
27
|
-
for (let i = 0; i < args.length; i++) {
|
|
28
|
-
let arg = args[i]!
|
|
29
|
-
if (arg === "--help" || arg === "-h") usage()
|
|
30
|
-
else if (arg === "-o" || arg === "--output") {
|
|
31
|
-
output = args[++i]
|
|
32
|
-
if (output === undefined) usage("Missing value for " + arg)
|
|
33
|
-
} else if (arg.startsWith("-")) usage("Unknown option " + arg)
|
|
34
|
-
else if (input === undefined) input = arg
|
|
35
|
-
else usage("Unexpected argument " + arg)
|
|
36
|
-
}
|
|
37
|
-
if (input === undefined) usage("Missing input file")
|
|
38
|
-
if (output === undefined) output = basename(input, extname(input)) + ".srtm"
|
|
39
|
-
|
|
40
|
-
let dir = dirname(input)
|
|
41
|
-
let bytes = new Uint8Array(readFileSync(input))
|
|
42
|
-
let started = performance.now()
|
|
43
|
-
let data = parseGltf(bytes, (uri) => new Uint8Array(readFileSync(join(dir, decodeURIComponent(uri)))))
|
|
44
|
-
let parsed = performance.now() - started
|
|
45
|
-
let encoded = encodeModel(data)
|
|
46
|
-
writeFileSync(output, encoded)
|
|
47
|
-
|
|
48
|
-
let triangles = data.parts.reduce((n, p) => n + p.geometry.indices.length / 3, 0)
|
|
49
|
-
let vertices = data.parts.reduce((n, p) => n + p.geometry.vertices.byteLength / layoutStride(p.geometry.layout), 0)
|
|
50
|
-
let targets = data.parts.reduce((n, p) => n + (p.geometry.morphs?.names.length ?? 0), 0)
|
|
51
|
-
console.log(
|
|
52
|
-
`${output}: ${data.nodes.length} nodes, ${data.parts.length} parts, ${vertices} vertices, ${triangles} triangles, ` +
|
|
53
|
-
(targets > 0 ? `${targets} morph targets, ` : "") +
|
|
54
|
-
`${data.clips.length} clips, ${data.materials.length} materials, ${data.images.length} images, ${(encoded.byteLength / 1024).toFixed(0)} KiB ` +
|
|
55
|
-
`(parsed in ${parsed.toFixed(0)} ms)`,
|
|
56
|
-
)
|