three-instance-batch 0.1.0 → 0.1.1
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 +5 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ inst.castShadow = true
|
|
|
28
28
|
batcher.addInstance(inst)
|
|
29
29
|
|
|
30
30
|
function animate() {
|
|
31
|
-
inst.position.
|
|
31
|
+
inst.position.setX(Math.sin(Date.now() * 0.001) * 5)
|
|
32
32
|
batcher.update(camera)
|
|
33
33
|
renderer.render(scene, camera)
|
|
34
34
|
requestAnimationFrame(animate)
|
|
@@ -39,7 +39,7 @@ No `setMatrixAt`. No `needsUpdate`. Just change properties and call `update()`.
|
|
|
39
39
|
|
|
40
40
|
## How It Works
|
|
41
41
|
|
|
42
|
-
`Instance` wraps `Vector3`, `Quaternion`, and `Color` setter methods at construction time. Any mutation — `position.set()`, `quaternion.setFromEuler()`, `color.setHSL()`, etc. — automatically marks that instance dirty.
|
|
42
|
+
`Instance` wraps `Vector3`, `Euler`, `Quaternion`, and `Color` setter methods at construction time. Any mutation via setter — `position.set()`, `rotation.set()`, `quaternion.setFromEuler()`, `color.setHSL()`, etc. — automatically marks that instance dirty. Note that direct property assignment (`position.x = 5`) is **not** tracked; use `setX()` or `set()` instead.
|
|
43
43
|
|
|
44
44
|
Instances are grouped into `InstancedMesh` objects by a **group key** derived from geometry UUID, material properties, and shadow flags. Instances sharing the same key share one draw call.
|
|
45
45
|
|
|
@@ -109,6 +109,7 @@ new Instance(geometry: BufferGeometry, material: Material)
|
|
|
109
109
|
| `material` | `Material` | Readonly |
|
|
110
110
|
| `position` | `Vector3` | Auto-tracked |
|
|
111
111
|
| `scale` | `Vector3` | Default `(1,1,1)`, auto-tracked |
|
|
112
|
+
| `rotation` | `Euler` | Auto-tracked; syncs to `quaternion` on change |
|
|
112
113
|
| `quaternion` | `Quaternion` | Auto-tracked |
|
|
113
114
|
| `color` | `Color` | Default white, auto-tracked |
|
|
114
115
|
| `visible` | `boolean` | Hidden instances write a zero matrix |
|
|
@@ -123,7 +124,7 @@ new Instance(geometry: BufferGeometry, material: Material)
|
|
|
123
124
|
| `isAncestorOf(other)` | `boolean` | |
|
|
124
125
|
| `dispose()` | `void` | Detaches from parent, detaches children, unsubscribes from all batchers |
|
|
125
126
|
|
|
126
|
-
> **Note:**
|
|
127
|
+
> **Note:** Only method calls (`.set()`, `.setX()`, `.copy()`, etc.) are tracked. Property assignment (`position.x = 5`) bypasses the wrapper. Use `setX()` / `setY()` / `setZ()` for single-component updates.
|
|
127
128
|
|
|
128
129
|
### `InstanceBatcher`
|
|
129
130
|
|
|
@@ -170,7 +171,7 @@ The real bottleneck at scale is GPU draw calls and vertex throughput, not JS-sid
|
|
|
170
171
|
|
|
171
172
|
## Known Limitations
|
|
172
173
|
|
|
173
|
-
- Frustum culling
|
|
174
|
+
- Frustum culling collects per-instance visibility but does not yet skip culled instances in the render pass.
|
|
174
175
|
|
|
175
176
|
## License
|
|
176
177
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-instance-batch",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Declarative instanced rendering for Three.js — Instance describes what, InstanceBatcher decides how to draw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/three-instance-batch.js",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|
|
28
|
-
"url": "https://github.com/
|
|
28
|
+
"url": "https://github.com/qiao-coding/three-instance-batch.git"
|
|
29
29
|
},
|
|
30
|
-
"author": "
|
|
30
|
+
"author": "qiao-coding",
|
|
31
31
|
"bugs": {
|
|
32
|
-
"url": "https://github.com/
|
|
32
|
+
"url": "https://github.com/qiao-coding/three-instance-batch/issues"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"three": ">=0.152.0"
|