@pinkaphant/kolmo 0.5.1 → 0.5.3
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 +92 -14
- package/dist/engine/actor.d.ts +1 -1
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.js +94 -441
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/surface.d.ts +5 -6
- package/dist/engine/traits.d.ts +27 -0
- package/dist/engine/world.d.ts +5 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -6
- package/dist/physics/index.d.ts +2 -1
- package/dist/physics/index.js +3 -1
- package/dist/physics-KYWAXctg.js +233 -0
- package/dist/physics-KYWAXctg.js.map +1 -0
- package/dist/replay/index.d.ts +84 -0
- package/dist/replay/index.js +380 -0
- package/dist/replay/index.js.map +1 -0
- package/dist/terrain/index.d.ts +119 -0
- package/dist/terrain/index.js +495 -0
- package/dist/terrain/index.js.map +1 -0
- package/dist/toolgun/Toolgun.d.ts +17 -6
- package/dist/toolgun/index.d.ts +2 -2
- package/dist/toolgun/index.js +1 -1
- package/dist/toolgun/store.d.ts +25 -75
- package/dist/{toolgun-BfcCIAQx.js → toolgun-COu_5SxS.js} +391 -673
- package/dist/toolgun-COu_5SxS.js.map +1 -0
- package/dist/traits-Dp1ey_4w.js +267 -0
- package/dist/traits-Dp1ey_4w.js.map +1 -0
- package/dist/vite/index.js +1 -0
- package/dist/vite/index.js.map +1 -1
- package/dist/water/index.d.ts +71 -0
- package/dist/water/index.js +442 -0
- package/dist/water/index.js.map +1 -0
- package/dist/{surface-DUol_5ml.js → world-BDhBihjW.js} +442 -57
- package/dist/world-BDhBihjW.js.map +1 -0
- package/docs/api-reference.md +201 -0
- package/package.json +25 -8
- package/dist/physics-ZDFXaCli.js +0 -475
- package/dist/physics-ZDFXaCli.js.map +0 -1
- package/dist/surface-DUol_5ml.js.map +0 -1
- package/dist/toolgun-BfcCIAQx.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_jsx"],"sources":["../../src/terrain/index.tsx"],"sourcesContent":["import React, { useEffect, useImperativeHandle, useMemo, useRef } from \"react\";\nimport * as THREE from \"three\";\nimport { useFrame } from \"@react-three/fiber\";\nimport { useRapier } from \"@react-three/rapier\";\nimport type RAPIER from \"@dimforge/rapier3d-compat\";\nimport {\n KHR_HEIGHTFIELD_FLAGS,\n KhrHeightfield,\n createHeightfieldGeometry,\n exportKhrGlb,\n type HeightfieldLayout,\n type KhrExportNodeSpec,\n} from \"@khr3/core\";\n\nexport type TerrainBrushMode = \"add\" | \"flatten\" | \"smooth\";\n\nexport interface TerrainBrushStamp {\n readonly x: number;\n readonly z: number;\n readonly radius: number;\n readonly strength: number;\n readonly mode?: TerrainBrushMode;\n readonly targetHeight?: number;\n}\n\nexport interface RollingBasinOptions {\n readonly amplitudeM?: number;\n readonly wavelengthM?: number;\n readonly basinRadiusM?: number;\n readonly basinDepthM?: number;\n readonly seed?: number;\n}\n\n/**\n * Smooth C^2 analytical height function producing a central lake basin surrounded by driveable banked ridges.\n */\nexport function createRollingBasinHeightFn(options: RollingBasinOptions = {}): (x: number, z: number) => number {\n const amp = options.amplitudeM ?? 3.6;\n const wl = Math.max(4, options.wavelengthM ?? 38);\n const basinR = Math.max(4, options.basinRadiusM ?? 22);\n const basinDepth = options.basinDepthM ?? 2.8;\n const seed = options.seed ?? 1337;\n const k1 = (2 * Math.PI) / wl;\n const k2 = k1 * 2.07;\n const p1 = (seed * 0.173) % (2 * Math.PI);\n const p2 = (seed * 0.619) % (2 * Math.PI);\n\n return (x: number, z: number): number => {\n const r = Math.hypot(x, z);\n const u = Math.min(1, r / basinR);\n // Quintic smoothstep S5(u) = 6u^5 - 15u^4 + 10u^3: zero 1st & 2nd derivatives at r=0 and r=basinR\n const s5 = u * u * u * (u * (u * 6 - 15) + 10);\n const hills =\n amp * (\n 0.62 * Math.sin(x * k1 + p1) * Math.cos(z * k1 - p2) +\n 0.26 * Math.cos((x * 0.8 + z * 0.6) * k2 + p2) +\n 0.12 * Math.sin((z * 0.85 - x * 0.52) * k2 * 1.6 - p1)\n );\n return -basinDepth * (1 - s5) + hills * (0.18 + 0.82 * s5);\n };\n}\n\nexport interface KolmoTerrainFieldOptions {\n readonly chunksX?: number;\n readonly chunksZ?: number;\n readonly cellsPerChunk?: number;\n readonly cellSizeM?: number;\n readonly originXZ?: readonly [number, number];\n readonly heightFn?: (x: number, z: number) => number;\n readonly friction?: number;\n readonly restitution?: number;\n}\n\nexport interface TerrainChunkBuffers {\n readonly key: number;\n readonly cx: number;\n readonly cz: number;\n readonly centerX: number;\n readonly centerZ: number;\n readonly spanM: number;\n /** Column-major `(N + 1) * (N + 1)` heights (`r + c * (N + 1)`) matching parry3d `ColliderDesc.heightfield`. */\n readonly rapierHeights: Float32Array;\n readonly geometry: THREE.BufferGeometry;\n}\n\n/**\n * Exact-math chunked heightfield storage whose indexed triangle diagonals (`(c1,r0)-(c0,r1)`)\n * match `parry3d` `ColliderDesc.heightfield` to 0 ulp, with cross-chunk C^1 vertex normals and `.glb` export.\n */\nexport class KolmoTerrainField {\n readonly chunksX: number;\n readonly chunksZ: number;\n readonly cellsPerChunk: number;\n readonly cellSizeM: number;\n readonly totalCellsX: number;\n readonly totalCellsZ: number;\n readonly vertsX: number;\n readonly vertsZ: number;\n readonly spanX: number;\n readonly spanZ: number;\n readonly minX: number;\n readonly minZ: number;\n readonly friction: number;\n readonly restitution: number;\n /** Global vertex height grid indexed as `gz * vertsX + gx`. */\n readonly heights: Float32Array;\n private readonly scratchHeights: Float32Array;\n private readonly sharedIndices: Uint32Array;\n private readonly chunks: TerrainChunkBuffers[] = [];\n private readonly dirtyChunks = new Set<number>();\n\n constructor(options: KolmoTerrainFieldOptions = {}) {\n const chunksX = Math.max(1, Math.trunc(options.chunksX ?? 4));\n const chunksZ = Math.max(1, Math.trunc(options.chunksZ ?? 4));\n const cellsPerChunk = Math.max(2, Math.trunc(options.cellsPerChunk ?? 24));\n const cellSizeM = options.cellSizeM ?? 1.5;\n if (!(cellSizeM > 0) || !Number.isFinite(cellSizeM)) {\n throw new RangeError(`KolmoTerrainField: cellSizeM must be positive finite, got ${cellSizeM}`);\n }\n this.chunksX = chunksX;\n this.chunksZ = chunksZ;\n this.cellsPerChunk = cellsPerChunk;\n this.cellSizeM = cellSizeM;\n this.totalCellsX = chunksX * cellsPerChunk;\n this.totalCellsZ = chunksZ * cellsPerChunk;\n this.vertsX = this.totalCellsX + 1;\n this.vertsZ = this.totalCellsZ + 1;\n this.spanX = this.totalCellsX * cellSizeM;\n this.spanZ = this.totalCellsZ * cellSizeM;\n const ox = options.originXZ?.[0] ?? 0;\n const oz = options.originXZ?.[1] ?? 0;\n this.minX = ox - this.spanX * 0.5;\n this.minZ = oz - this.spanZ * 0.5;\n this.friction = options.friction ?? 0.85;\n this.restitution = options.restitution ?? 0.04;\n\n this.heights = new Float32Array(this.vertsX * this.vertsZ);\n this.scratchHeights = new Float32Array(this.vertsX * this.vertsZ);\n\n const fn = options.heightFn ?? createRollingBasinHeightFn();\n for (let gz = 0; gz < this.vertsZ; gz++) {\n const z = this.minZ + gz * cellSizeM;\n const rowOff = gz * this.vertsX;\n for (let gx = 0; gx < this.vertsX; gx++) {\n const x = this.minX + gx * cellSizeM;\n const y = fn(x, z);\n if (!Number.isFinite(y)) {\n throw new RangeError(`KolmoTerrainField: non-finite height at (${x}, ${z})`);\n }\n this.heights[rowOff + gx] = y;\n }\n }\n\n // Shared anti-diagonal quad triangulation matching parry3d HeightField:\n // Triangle 0: (i00, i01, i10), Triangle 1: (i10, i01, i11) — CCW +Y front-facing\n const n = cellsPerChunk;\n const stride = n + 1;\n const idx = new Uint32Array(n * n * 6);\n let p = 0;\n for (let r = 0; r < n; r++) {\n for (let c = 0; c < n; c++) {\n const i00 = r * stride + c;\n const i10 = i00 + 1;\n const i01 = (r + 1) * stride + c;\n const i11 = i01 + 1;\n idx[p++] = i00;\n idx[p++] = i01;\n idx[p++] = i10;\n idx[p++] = i10;\n idx[p++] = i01;\n idx[p++] = i11;\n }\n }\n this.sharedIndices = idx;\n\n const chunkSpan = n * cellSizeM;\n const vertCount = stride * stride;\n for (let cz = 0; cz < chunksZ; cz++) {\n for (let cx = 0; cx < chunksX; cx++) {\n const key = cz * chunksX + cx;\n const centerX = this.minX + (cx + 0.5) * chunkSpan;\n const centerZ = this.minZ + (cz + 0.5) * chunkSpan;\n const posArr = new Float32Array(vertCount * 3);\n const nrmArr = new Float32Array(vertCount * 3);\n const uvArr = new Float32Array(vertCount * 2);\n\n for (let r = 0; r <= n; r++) {\n const lz = -chunkSpan * 0.5 + r * cellSizeM;\n const gz = cz * n + r;\n for (let c = 0; c <= n; c++) {\n const lx = -chunkSpan * 0.5 + c * cellSizeM;\n const gx = cx * n + c;\n const vi = r * stride + c;\n posArr[vi * 3 + 0] = lx;\n posArr[vi * 3 + 2] = lz;\n uvArr[vi * 2 + 0] = gx / this.totalCellsX;\n uvArr[vi * 2 + 1] = gz / this.totalCellsZ;\n }\n }\n\n const geo = new THREE.BufferGeometry();\n geo.setAttribute(\"position\", new THREE.BufferAttribute(posArr, 3));\n geo.setAttribute(\"normal\", new THREE.BufferAttribute(nrmArr, 3));\n geo.setAttribute(\"uv\", new THREE.BufferAttribute(uvArr, 2));\n geo.setIndex(new THREE.BufferAttribute(this.sharedIndices, 1));\n\n const chunk: TerrainChunkBuffers = {\n key,\n cx,\n cz,\n centerX,\n centerZ,\n spanM: chunkSpan,\n rapierHeights: new Float32Array(vertCount),\n geometry: geo,\n };\n this.chunks.push(chunk);\n this.syncChunkBuffers(chunk);\n }\n }\n }\n\n getChunks(): readonly TerrainChunkBuffers[] {\n return this.chunks;\n }\n\n private syncChunkBuffers(chunk: TerrainChunkBuffers): void {\n const n = this.cellsPerChunk;\n const stride = n + 1;\n const posAttr = chunk.geometry.getAttribute(\"position\") as THREE.BufferAttribute;\n const nrmAttr = chunk.geometry.getAttribute(\"normal\") as THREE.BufferAttribute;\n const pos = posAttr.array as Float32Array;\n const nrm = nrmAttr.array as Float32Array;\n const hCol = chunk.rapierHeights;\n const invCell = 1 / this.cellSizeM;\n\n for (let r = 0; r <= n; r++) {\n const gz = chunk.cz * n + r;\n const gzPrev = gz > 0 ? gz - 1 : 0;\n const gzNext = gz < this.totalCellsZ ? gz + 1 : this.totalCellsZ;\n const dzScale = invCell / Math.max(1, gzNext - gzPrev);\n\n for (let c = 0; c <= n; c++) {\n const gx = chunk.cx * n + c;\n const gxPrev = gx > 0 ? gx - 1 : 0;\n const gxNext = gx < this.totalCellsX ? gx + 1 : this.totalCellsX;\n const dxScale = invCell / Math.max(1, gxNext - gxPrev);\n\n const h = this.heights[gz * this.vertsX + gx];\n const vi = r * stride + c;\n pos[vi * 3 + 1] = h;\n // Column-major index r + c * (n + 1) required by Rapier ColliderDesc.heightfield\n hCol[r + c * stride] = h;\n\n const hx = (this.heights[gz * this.vertsX + gxNext] - this.heights[gz * this.vertsX + gxPrev]) * dxScale;\n const hz = (this.heights[gzNext * this.vertsX + gx] - this.heights[gzPrev * this.vertsX + gx]) * dzScale;\n const invLen = 1 / Math.hypot(hx, 1, hz);\n nrm[vi * 3 + 0] = -hx * invLen;\n nrm[vi * 3 + 1] = invLen;\n nrm[vi * 3 + 2] = -hz * invLen;\n }\n }\n\n posAttr.needsUpdate = true;\n nrmAttr.needsUpdate = true;\n chunk.geometry.computeBoundingSphere();\n chunk.geometry.computeBoundingBox();\n }\n\n /**\n * Evaluates the exact piecewise-linear surface height matching `parry3d` `HeightField`'s anti-diagonal triangles.\n */\n sampleHeight(x: number, z: number): number {\n const fx = Math.min(this.totalCellsX, Math.max(0, (x - this.minX) / this.cellSizeM));\n const fz = Math.min(this.totalCellsZ, Math.max(0, (z - this.minZ) / this.cellSizeM));\n const gx = Math.min(this.totalCellsX - 1, Math.floor(fx));\n const gz = Math.min(this.totalCellsZ - 1, Math.floor(fz));\n const u = fx - gx;\n const v = fz - gz;\n\n const i00 = gz * this.vertsX + gx;\n const h00 = this.heights[i00];\n const h10 = this.heights[i00 + 1];\n const h01 = this.heights[i00 + this.vertsX];\n const h11 = this.heights[i00 + this.vertsX + 1];\n\n if (u + v <= 1) {\n return h00 * (1 - u - v) + h10 * u + h01 * v;\n }\n return h11 * (u + v - 1) + h10 * (1 - v) + h01 * (1 - u);\n }\n\n /**\n * Evaluates the exact facet normal of the active anti-diagonal heightfield triangle at `(x, z)`.\n */\n sampleNormal(x: number, z: number, out = new THREE.Vector3()): THREE.Vector3 {\n const fx = Math.min(this.totalCellsX, Math.max(0, (x - this.minX) / this.cellSizeM));\n const fz = Math.min(this.totalCellsZ, Math.max(0, (z - this.minZ) / this.cellSizeM));\n const gx = Math.min(this.totalCellsX - 1, Math.floor(fx));\n const gz = Math.min(this.totalCellsZ - 1, Math.floor(fz));\n const u = fx - gx;\n const v = fz - gz;\n\n const i00 = gz * this.vertsX + gx;\n const h00 = this.heights[i00];\n const h10 = this.heights[i00 + 1];\n const h01 = this.heights[i00 + this.vertsX];\n const h11 = this.heights[i00 + this.vertsX + 1];\n const inv = 1 / this.cellSizeM;\n\n const dhdx = (u + v <= 1 ? h10 - h00 : h11 - h01) * inv;\n const dhdz = (u + v <= 1 ? h01 - h00 : h11 - h10) * inv;\n return out.set(-dhdx, 1, -dhdz).normalize();\n }\n\n /**\n * Sculpts the terrain with a C^2 radial falloff brush and marks only affected chunks (plus 1-vertex normal halo) dirty.\n */\n applyBrush(stamp: TerrainBrushStamp): number {\n const radius = Math.max(this.cellSizeM, stamp.radius);\n const mode = stamp.mode ?? \"add\";\n const gxMin = Math.max(0, Math.floor((stamp.x - radius - this.minX) / this.cellSizeM));\n const gxMax = Math.min(this.totalCellsX, Math.ceil((stamp.x + radius - this.minX) / this.cellSizeM));\n const gzMin = Math.max(0, Math.floor((stamp.z - radius - this.minZ) / this.cellSizeM));\n const gzMax = Math.min(this.totalCellsZ, Math.ceil((stamp.z + radius - this.minZ) / this.cellSizeM));\n if (gxMin > gxMax || gzMin > gzMax)\n return 0;\n\n const targetH = stamp.targetHeight ?? this.sampleHeight(stamp.x, stamp.z);\n const r2 = radius * radius;\n\n if (mode === \"smooth\") {\n for (let gz = gzMin; gz <= gzMax; gz++) {\n for (let gx = gxMin; gx <= gxMax; gx++) {\n const xm = Math.max(0, gx - 1), xp = Math.min(this.totalCellsX, gx + 1);\n const zm = Math.max(0, gz - 1), zp = Math.min(this.totalCellsZ, gz + 1);\n this.scratchHeights[gz * this.vertsX + gx] =\n 0.25 * (\n this.heights[gz * this.vertsX + xm] +\n this.heights[gz * this.vertsX + xp] +\n this.heights[zm * this.vertsX + gx] +\n this.heights[zp * this.vertsX + gx]\n );\n }\n }\n }\n\n let touchedVerts = 0;\n for (let gz = gzMin; gz <= gzMax; gz++) {\n const z = this.minZ + gz * this.cellSizeM;\n const dz = z - stamp.z;\n for (let gx = gxMin; gx <= gxMax; gx++) {\n const x = this.minX + gx * this.cellSizeM;\n const dx = x - stamp.x;\n const d2 = dx * dx + dz * dz;\n if (d2 >= r2)\n continue;\n const t = 1 - Math.sqrt(d2) / radius;\n const weight = t * t * (3 - 2 * t);\n const idx = gz * this.vertsX + gx;\n const cur = this.heights[idx];\n\n if (mode === \"add\") {\n this.heights[idx] = cur + stamp.strength * weight;\n }\n else if (mode === \"flatten\") {\n const alpha = Math.min(1, Math.max(0, stamp.strength) * weight);\n this.heights[idx] = cur + (targetH - cur) * alpha;\n }\n else {\n const alpha = Math.min(1, Math.max(0, stamp.strength) * weight);\n this.heights[idx] = cur + (this.scratchHeights[idx] - cur) * alpha;\n }\n touchedVerts++;\n }\n }\n\n if (touchedVerts === 0)\n return 0;\n\n // Include 1-vertex halo so shared boundary normals stay exact across neighbor chunks\n const n = this.cellsPerChunk;\n const cx0 = Math.max(0, Math.floor(Math.max(0, gxMin - 1) / n));\n const cx1 = Math.min(this.chunksX - 1, Math.floor(Math.min(this.totalCellsX, gxMax + 1) / n));\n const cz0 = Math.max(0, Math.floor(Math.max(0, gzMin - 1) / n));\n const cz1 = Math.min(this.chunksZ - 1, Math.floor(Math.min(this.totalCellsZ, gzMax + 1) / n));\n\n for (let cz = cz0; cz <= cz1; cz++) {\n for (let cx = cx0; cx <= cx1; cx++) {\n const key = cz * this.chunksX + cx;\n this.syncChunkBuffers(this.chunks[key]);\n this.dirtyChunks.add(key);\n }\n }\n return touchedVerts;\n }\n\n consumeDirtyChunks(): TerrainChunkBuffers[] {\n if (this.dirtyChunks.size === 0)\n return [];\n const out: TerrainChunkBuffers[] = [];\n for (const key of this.dirtyChunks) {\n out.push(this.chunks[key]);\n }\n this.dirtyChunks.clear();\n return out;\n }\n\n dispose(): void {\n for (const chunk of this.chunks) {\n chunk.geometry.dispose();\n }\n }\n}\n\n/**\n * Exports a `KolmoTerrainField` as a Khronos-compliant `KHR_physics_rigid_bodies` `.glb` binary\n * with indexed static trimesh colliders (`convexHull: false`), ready to round-trip via `loadKhrGlb`.\n */\nexport async function exportTerrainKhrGlb(\n field: KolmoTerrainField,\n material?: THREE.Material,\n): Promise<Uint8Array> {\n const root = new THREE.Group();\n root.name = \"KolmoTerrain\";\n const ownMat = !material;\n const mat = material ?? new THREE.MeshStandardMaterial({ color: \"#4d6b53\", roughness: 0.88, metalness: 0.04 });\n const specs: KhrExportNodeSpec[] = [];\n\n for (const chunk of field.getChunks()) {\n const nodeName = `TerrainChunk_${chunk.cx}_${chunk.cz}`;\n const mesh = new THREE.Mesh(chunk.geometry, mat);\n mesh.name = nodeName;\n mesh.position.set(chunk.centerX, 0, chunk.centerZ);\n root.add(mesh);\n specs.push({\n nodeName,\n collider: {\n meshNodeName: nodeName,\n convexHull: false,\n friction: field.friction,\n restitution: field.restitution,\n },\n });\n }\n\n try {\n return new Uint8Array(await exportKhrGlb(root, specs));\n }\n finally {\n if (ownMat)\n mat.dispose();\n }\n}\n\nexport interface KolmoTerrainHandle {\n readonly field: KolmoTerrainField;\n readonly body: RAPIER.RigidBody | null;\n applyBrush: (stamp: TerrainBrushStamp) => number;\n exportGlb: () => Promise<Uint8Array>;\n}\n\nexport interface KolmoTerrainProps extends KolmoTerrainFieldOptions {\n readonly ref?: React.Ref<KolmoTerrainHandle>;\n readonly field?: KolmoTerrainField;\n /** Optional pre-sampled height array (e.g. `@khr3/roads` `sampleRapierHeightfield` or `sampleHeightfield`). */\n readonly heights?: Float32Array;\n /** Cell subdivisions `n` or `[nrows (Z), ncols (X)]` when `heights` is provided (default `128`). */\n readonly segments?: number | readonly [nrows: number, ncols: number];\n /** World footprint `sizeM` or `[sizeX, sizeZ]` when `heights` is provided (default `[200, 200]`). */\n readonly size?: number | readonly [sizeX: number, sizeZ: number];\n /** World position `[x, y, z]` when `heights` is provided (default `[originXZ[0], 0, originXZ[1]]`). */\n readonly position?: readonly [number, number, number];\n /** Array layout when `heights` is provided (`\"rapier-column-major\"` default, or `\"row-major\"`). */\n readonly layout?: HeightfieldLayout;\n readonly color?: string;\n readonly material?: THREE.Material;\n readonly wireframe?: boolean;\n readonly receiveShadow?: boolean;\n readonly castShadow?: boolean;\n}\n\nfunction ExplicitHeightfieldTerrain({\n heights,\n segments = 128,\n size = [200, 200],\n position,\n originXZ,\n layout = \"rapier-column-major\",\n friction = 0.85,\n restitution = 0.04,\n color = \"#4b6b50\",\n material: externalMaterial,\n wireframe = false,\n receiveShadow = true,\n castShadow = false,\n}: {\n heights: Float32Array;\n segments?: number | readonly [number, number];\n size?: number | readonly [number, number];\n position?: readonly [number, number, number];\n originXZ?: readonly [number, number];\n layout?: HeightfieldLayout;\n friction?: number;\n restitution?: number;\n color?: string;\n material?: THREE.Material;\n wireframe?: boolean;\n receiveShadow?: boolean;\n castShadow?: boolean;\n}): React.JSX.Element {\n const nrows = typeof segments === \"number\" ? segments : segments[0];\n const ncols = typeof segments === \"number\" ? segments : segments[1];\n const sizeX = typeof size === \"number\" ? size : size[0];\n const sizeZ = typeof size === \"number\" ? size : size[1];\n const pos: [number, number, number] = position\n ? [position[0], position[1], position[2]]\n : [originXZ?.[0] ?? 0, 0, originXZ?.[1] ?? 0];\n\n const geo = useMemo(\n () => createHeightfieldGeometry(heights, sizeX, sizeZ, nrows, ncols, layout),\n [heights, sizeX, sizeZ, nrows, ncols, layout],\n );\n useEffect(() => () => geo.dispose(), [geo]);\n\n const defaultMat = useMemo(\n () =>\n externalMaterial\n ? null\n : new THREE.MeshStandardMaterial({ color, roughness: 0.88, metalness: 0.04, wireframe }),\n [externalMaterial, color, wireframe],\n );\n useEffect(() => () => defaultMat?.dispose(), [defaultMat]);\n const mat = externalMaterial ?? defaultMat!;\n\n return (\n <KhrHeightfield\n heights={heights}\n segments={[nrows, ncols]}\n size={[sizeX, sizeZ]}\n position={pos}\n layout={layout}\n friction={friction}\n restitution={restitution}\n userData={{ name: \"KolmoTerrain\" }}\n >\n <mesh geometry={geo} material={mat} receiveShadow={receiveShadow} castShadow={castShadow} />\n </KhrHeightfield>\n );\n}\n\nexport function KolmoTerrain(props: KolmoTerrainProps): React.JSX.Element {\n if (props.heights) {\n return (\n <ExplicitHeightfieldTerrain\n heights={props.heights}\n segments={props.segments}\n size={props.size}\n position={props.position}\n originXZ={props.originXZ}\n layout={props.layout}\n friction={props.friction}\n restitution={props.restitution}\n color={props.color}\n material={props.material}\n wireframe={props.wireframe}\n receiveShadow={props.receiveShadow}\n castShadow={props.castShadow}\n />\n );\n }\n return <ChunkedKolmoTerrain {...props} />;\n}\n\nfunction ChunkedKolmoTerrain({\n ref,\n field: externalField,\n chunksX,\n chunksZ,\n cellsPerChunk,\n cellSizeM,\n originXZ,\n heightFn,\n friction,\n restitution,\n color = \"#4b6b50\",\n material: externalMaterial,\n wireframe = false,\n receiveShadow = true,\n castShadow = false,\n}: KolmoTerrainProps): React.JSX.Element {\n const { rapier, world } = useRapier();\n\n const ownedField = useMemo(\n () =>\n externalField ??\n new KolmoTerrainField({\n chunksX,\n chunksZ,\n cellsPerChunk,\n cellSizeM,\n originXZ,\n heightFn,\n friction,\n restitution,\n }),\n [externalField, chunksX, chunksZ, cellsPerChunk, cellSizeM, originXZ, heightFn, friction, restitution],\n );\n\n useEffect(() => {\n if (externalField)\n return;\n return () => ownedField.dispose();\n }, [externalField, ownedField]);\n\n const defaultMat = useMemo(\n () =>\n externalMaterial\n ? null\n : new THREE.MeshStandardMaterial({ color, roughness: 0.88, metalness: 0.04, wireframe }),\n [externalMaterial, color, wireframe],\n );\n useEffect(() => () => defaultMat?.dispose(), [defaultMat]);\n const mat = externalMaterial ?? defaultMat!;\n\n const bodyRef = useRef<RAPIER.RigidBody | null>(null);\n const collidersRef = useRef<Map<number, RAPIER.Collider>>(new Map());\n\n const buildChunkCollider = (body: RAPIER.RigidBody, chunk: TerrainChunkBuffers): RAPIER.Collider => {\n const n = ownedField.cellsPerChunk;\n const desc = (rapier.ColliderDesc as unknown as {\n heightfield: (nr: number, nc: number, h: Float32Array, s: { x: number; y: number; z: number }, flags?: number) => RAPIER.ColliderDesc;\n }).heightfield(\n n,\n n,\n chunk.rapierHeights,\n { x: chunk.spanM, y: 1, z: chunk.spanM },\n KHR_HEIGHTFIELD_FLAGS,\n )\n .setTranslation(chunk.centerX, 0, chunk.centerZ)\n .setFriction(ownedField.friction)\n .setRestitution(ownedField.restitution);\n return world.createCollider(desc, body);\n };\n\n useEffect(() => {\n const body = world.createRigidBody(rapier.RigidBodyDesc.fixed());\n body.userData = { name: \"KolmoTerrain\" };\n bodyRef.current = body;\n const map = new Map<number, RAPIER.Collider>();\n ownedField.consumeDirtyChunks();\n for (const chunk of ownedField.getChunks()) {\n map.set(chunk.key, buildChunkCollider(body, chunk));\n }\n collidersRef.current = map;\n\n return () => {\n collidersRef.current.clear();\n bodyRef.current = null;\n if (world.getRigidBody(body.handle)) {\n world.removeRigidBody(body);\n }\n };\n }, [rapier, world, ownedField]);\n\n useFrame(() => {\n const body = bodyRef.current;\n if (!body)\n return;\n const dirty = ownedField.consumeDirtyChunks();\n if (dirty.length === 0)\n return;\n for (const chunk of dirty) {\n const prev = collidersRef.current.get(chunk.key);\n if (prev && world.getCollider(prev.handle)) {\n world.removeCollider(prev, false);\n }\n collidersRef.current.set(chunk.key, buildChunkCollider(body, chunk));\n }\n });\n\n useImperativeHandle(\n ref,\n () => ({\n field: ownedField,\n get body() {\n return bodyRef.current;\n },\n applyBrush: (stamp) => ownedField.applyBrush(stamp),\n exportGlb: () => exportTerrainKhrGlb(ownedField, mat),\n }),\n [ownedField, mat],\n );\n\n return (\n <group name=\"KolmoTerrain\">\n {ownedField.getChunks().map((chunk) => (\n <mesh\n key={chunk.key}\n position={[chunk.centerX, 0, chunk.centerZ]}\n geometry={chunk.geometry}\n material={mat}\n receiveShadow={receiveShadow}\n castShadow={castShadow}\n />\n ))}\n </group>\n );\n}\n"],"mappings":";;;;;;;;;;AAoCA,SAAgB,2BAA2B,UAA+B,CAAC,GAAqC;CAC5G,MAAM,MAAM,QAAQ,cAAc;CAClC,MAAM,KAAK,KAAK,IAAI,GAAG,QAAQ,eAAe,EAAE;CAChD,MAAM,SAAS,KAAK,IAAI,GAAG,QAAQ,gBAAgB,EAAE;CACrD,MAAM,aAAa,QAAQ,eAAe;CAC1C,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,KAAM,IAAI,KAAK,KAAM;CAC3B,MAAM,KAAK,KAAK;CAChB,MAAM,KAAM,OAAO,QAAU,IAAI,KAAK;CACtC,MAAM,KAAM,OAAO,QAAU,IAAI,KAAK;CAEtC,QAAQ,GAAW,MAAsB;EAErC,MAAM,IAAI,KAAK,IAAI,GADT,KAAK,MAAM,GAAG,CACF,IAAI,MAAM;EAEhC,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM;EAC3C,MAAM,QACF,OACI,MAAO,KAAK,IAAI,IAAI,KAAK,EAAE,IAAI,KAAK,IAAI,IAAI,KAAK,EAAE,IACnD,MAAO,KAAK,KAAK,IAAI,KAAM,IAAI,MAAO,KAAK,EAAE,IAC7C,MAAO,KAAK,KAAK,IAAI,MAAO,IAAI,OAAQ,KAAK,MAAM,EAAE;EAE7D,OAAO,CAAC,cAAc,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xD,IACA,CAAC,YAAY,GAAG,CACpB;CAEA,OACIA,oBAAC,SAAD;EAAO,MAAK;EACP,UAAA,WAAW,UAAU,CAAC,CAAC,KAAK,UACzBA,oBAAC,QAAD;GAEI,UAAU;IAAC,MAAM;IAAS;IAAG,MAAM;GAAO;GAC1C,UAAU,MAAM;GAChB,UAAU;GACK;GACH;EACf,GANQ,MAAM,GAMd,CACJ;CACE,CAAA;AAEf"}
|
|
@@ -2,16 +2,25 @@ import React from "react";
|
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import type { EcctrlHandle } from "@pinkaphant/ecctrl";
|
|
4
4
|
import { type KhrAssetBundle } from "@khr3/core";
|
|
5
|
-
import { type
|
|
5
|
+
import { type PieceKind } from "@khr3/c12";
|
|
6
|
+
import { type ArmedToolgunAsset, type ToolgunActionOutcome } from "./store.js";
|
|
7
|
+
export declare const DEFAULT_VAULT_C12_URLS: Readonly<Record<PieceKind, string>>;
|
|
8
|
+
export interface MeasuredToolgunScreen {
|
|
9
|
+
readonly pos: [number, number, number];
|
|
10
|
+
readonly quat: [number, number, number, number];
|
|
11
|
+
readonly size: [number, number];
|
|
12
|
+
}
|
|
6
13
|
export interface MeasuredToolgunViewmodel {
|
|
7
14
|
readonly scene: THREE.Object3D;
|
|
8
15
|
readonly gripOffset: [number, number, number];
|
|
9
16
|
readonly muzzleLocal: [number, number, number];
|
|
10
|
-
readonly
|
|
11
|
-
readonly screenQuat: [number, number, number, number];
|
|
12
|
-
readonly screenSize: [number, number];
|
|
17
|
+
readonly screen: MeasuredToolgunScreen | null;
|
|
13
18
|
}
|
|
14
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Measures grip, muzzle, and optional LCD bezel (`screen_rect` / `lcd_screen`) sockets on an already-cloned viewmodel scene.
|
|
21
|
+
* Offsets the LCD quad 1mm along `screen_rect`'s local +Z normal in root space so arbitrary bezel orientations never z-fight.
|
|
22
|
+
*/
|
|
23
|
+
export declare function measureToolgunViewmodel(clonedScene: THREE.Object3D): MeasuredToolgunViewmodel;
|
|
15
24
|
export interface KolmoToolgunHandle {
|
|
16
25
|
fire: (shiftKey?: boolean) => ToolgunActionOutcome;
|
|
17
26
|
undo: () => string;
|
|
@@ -20,8 +29,10 @@ export interface KolmoToolgunProps {
|
|
|
20
29
|
readonly ref?: React.Ref<KolmoToolgunHandle>;
|
|
21
30
|
readonly src?: string;
|
|
22
31
|
readonly bundle?: KhrAssetBundle | null;
|
|
32
|
+
readonly c12Bundles?: Partial<Record<PieceKind, KhrAssetBundle>>;
|
|
33
|
+
readonly c12Urls?: Partial<Record<PieceKind, string>> | null;
|
|
23
34
|
readonly actorRef?: React.RefObject<EcctrlHandle | null>;
|
|
24
|
-
readonly
|
|
35
|
+
readonly accentColor?: string;
|
|
25
36
|
readonly defaultArmedAsset?: ArmedToolgunAsset | null;
|
|
26
37
|
readonly maxRangeM?: number;
|
|
27
38
|
readonly hipOffset?: readonly [number, number, number];
|
package/dist/toolgun/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
1
|
+
export * from "./store.js";
|
|
2
|
+
export { DEFAULT_VAULT_C12_URLS, KolmoToolgun, measureToolgunViewmodel, type KolmoToolgunHandle, type KolmoToolgunProps, type MeasuredToolgunScreen, type MeasuredToolgunViewmodel, } from "./Toolgun.js";
|
package/dist/toolgun/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as
|
|
1
|
+
export { t as DEFAULT_VAULT_C12_URLS, n as KolmoToolgun, i as TOOLGUN_BUILD_KINDS, a as TOOLGUN_MODES, o as castToolgunRay, s as computeAlignedSpawnPose, c as computeBuildCandidate, l as createHingeImpulseJoint, u as createToolgunStore, d as createWeldImpulseJoint, f as isSameBuildPreview, r as measureToolgunViewmodel, p as rigJointRuntime, m as useToolgunStore } from "../toolgun-COu_5SxS.js";
|
package/dist/toolgun/store.d.ts
CHANGED
|
@@ -6,58 +6,6 @@ export declare const TOOLGUN_MODES: readonly ["spawn", "weld", "hinge", "rig", "
|
|
|
6
6
|
export type ToolgunMode = (typeof TOOLGUN_MODES)[number];
|
|
7
7
|
export declare const TOOLGUN_BUILD_KINDS: readonly ["FoundationSquare", "FoundationTriangle", "Wall", "Doorway", "Floor", "FloorTriangle", "Roof", "RoofTriangle", "Stairs"];
|
|
8
8
|
export type ToolgunBuildKind = (typeof TOOLGUN_BUILD_KINDS)[number];
|
|
9
|
-
export interface ToolgunSkinSpec {
|
|
10
|
-
readonly bodyHex: string;
|
|
11
|
-
readonly accentHex: string;
|
|
12
|
-
readonly emissiveHex: string;
|
|
13
|
-
readonly metalness: number;
|
|
14
|
-
readonly roughness: number;
|
|
15
|
-
}
|
|
16
|
-
export declare const TOOLGUN_SKIN_PRESETS: {
|
|
17
|
-
readonly cobalt: {
|
|
18
|
-
readonly bodyHex: "#1e293b";
|
|
19
|
-
readonly accentHex: "#38bdf8";
|
|
20
|
-
readonly emissiveHex: "#0ea5e9";
|
|
21
|
-
readonly metalness: 0.65;
|
|
22
|
-
readonly roughness: 0.32;
|
|
23
|
-
};
|
|
24
|
-
readonly hazard: {
|
|
25
|
-
readonly bodyHex: "#292524";
|
|
26
|
-
readonly accentHex: "#f59e0b";
|
|
27
|
-
readonly emissiveHex: "#d97706";
|
|
28
|
-
readonly metalness: 0.55;
|
|
29
|
-
readonly roughness: 0.38;
|
|
30
|
-
};
|
|
31
|
-
readonly stealth: {
|
|
32
|
-
readonly bodyHex: "#0f172a";
|
|
33
|
-
readonly accentHex: "#64748b";
|
|
34
|
-
readonly emissiveHex: "#38bdf8";
|
|
35
|
-
readonly metalness: 0.72;
|
|
36
|
-
readonly roughness: 0.28;
|
|
37
|
-
};
|
|
38
|
-
readonly chrome: {
|
|
39
|
-
readonly bodyHex: "#cbd5e1";
|
|
40
|
-
readonly accentHex: "#0284c7";
|
|
41
|
-
readonly emissiveHex: "#38bdf8";
|
|
42
|
-
readonly metalness: 0.92;
|
|
43
|
-
readonly roughness: 0.14;
|
|
44
|
-
};
|
|
45
|
-
readonly arctic: {
|
|
46
|
-
readonly bodyHex: "#f1f5f9";
|
|
47
|
-
readonly accentHex: "#06b6d4";
|
|
48
|
-
readonly emissiveHex: "#22d3ee";
|
|
49
|
-
readonly metalness: 0.35;
|
|
50
|
-
readonly roughness: 0.42;
|
|
51
|
-
};
|
|
52
|
-
readonly ember: {
|
|
53
|
-
readonly bodyHex: "#1c1917";
|
|
54
|
-
readonly accentHex: "#ef4444";
|
|
55
|
-
readonly emissiveHex: "#f97316";
|
|
56
|
-
readonly metalness: 0.62;
|
|
57
|
-
readonly roughness: 0.34;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export type ToolgunSkinPreset = keyof typeof TOOLGUN_SKIN_PRESETS;
|
|
61
9
|
export interface ArmedToolgunAsset {
|
|
62
10
|
readonly id: string;
|
|
63
11
|
readonly name: string;
|
|
@@ -79,21 +27,20 @@ export interface SpawnedToolgunEntity {
|
|
|
79
27
|
export interface CreatedToolgunJoint {
|
|
80
28
|
readonly id: string;
|
|
81
29
|
readonly kind: "weld" | "hinge";
|
|
30
|
+
readonly world: RAPIER.World;
|
|
82
31
|
readonly handle: number;
|
|
83
32
|
readonly joint: RAPIER.ImpulseJoint;
|
|
84
33
|
readonly anchorWorld: [number, number, number];
|
|
85
34
|
}
|
|
86
|
-
export interface
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
readonly label: string;
|
|
93
|
-
readonly spawnedEntityId?: string;
|
|
94
|
-
readonly placedPieceId?: string;
|
|
35
|
+
export interface ToolgunRaycastResult {
|
|
36
|
+
point: [number, number, number];
|
|
37
|
+
normal: [number, number, number];
|
|
38
|
+
toi: number;
|
|
39
|
+
collider: RAPIER.Collider;
|
|
40
|
+
body: RAPIER.RigidBody | null;
|
|
95
41
|
}
|
|
96
42
|
export interface PendingJointAnchor {
|
|
43
|
+
readonly world: RAPIER.World;
|
|
97
44
|
readonly body: RAPIER.RigidBody;
|
|
98
45
|
readonly worldPoint: [number, number, number];
|
|
99
46
|
readonly worldNormal: [number, number, number];
|
|
@@ -123,18 +70,18 @@ export interface ToolgunActionOutcome {
|
|
|
123
70
|
readonly status: string;
|
|
124
71
|
readonly beamEnd: [number, number, number];
|
|
125
72
|
}
|
|
73
|
+
type Vec3Input = {
|
|
74
|
+
readonly x: number;
|
|
75
|
+
readonly y: number;
|
|
76
|
+
readonly z: number;
|
|
77
|
+
} | readonly [number, number, number];
|
|
126
78
|
/**
|
|
127
|
-
* Casts a solid ray against Rapier WASM colliders
|
|
79
|
+
* Casts a solid ray against Rapier WASM colliders using `QueryFilterFlags.EXCLUDE_SENSORS`,
|
|
80
|
+
* ignoring the optional actor `RigidBody`. Pass `out` on hot `useFrame` paths for zero heap allocations.
|
|
128
81
|
*/
|
|
129
|
-
export declare function castToolgunRay(rapier: typeof RAPIER, world: RAPIER.World, origin:
|
|
130
|
-
point: [number, number, number];
|
|
131
|
-
normal: [number, number, number];
|
|
132
|
-
toi: number;
|
|
133
|
-
collider: RAPIER.Collider;
|
|
134
|
-
body: RAPIER.RigidBody | null;
|
|
135
|
-
} | null;
|
|
82
|
+
export declare function castToolgunRay(rapier: typeof RAPIER, world: RAPIER.World, origin: Vec3Input, direction: Vec3Input, maxRange?: number, excludeBody?: RAPIER.RigidBody | null, out?: ToolgunRaycastResult): ToolgunRaycastResult | null;
|
|
136
83
|
/**
|
|
137
|
-
* Aligns a spawned asset's +Y axis to `surfaceNormal` (when sloped) composed with exact 30° `yaw12` turn.
|
|
84
|
+
* Aligns a spawned asset's +Y axis to `surfaceNormal` (when sloped <= 55°) composed with exact 30° `yaw12` turn.
|
|
138
85
|
*/
|
|
139
86
|
export declare function computeAlignedSpawnPose(point: readonly [number, number, number], yaw12: number, surfaceNormal?: readonly [number, number, number], clearanceM?: number): {
|
|
140
87
|
position: [number, number, number];
|
|
@@ -153,18 +100,21 @@ export declare function createHingeImpulseJoint(rapier: typeof RAPIER, world: RA
|
|
|
153
100
|
* Toggles or breaks an articulated `@khr3/core` `JointRuntime`.
|
|
154
101
|
*/
|
|
155
102
|
export declare function rigJointRuntime(rt: JointRuntime, severBreakaway?: boolean): string;
|
|
103
|
+
/**
|
|
104
|
+
* Exact equality check for `BuildSnapCandidate` using `@khr3/c12`'s `poseEq`
|
|
105
|
+
* (avoiding float quaternion sign collisions such as 60° vs 300° where `qy === 0.5`).
|
|
106
|
+
*/
|
|
107
|
+
export declare function isSameBuildPreview(a: BuildSnapCandidate | null, b: BuildSnapCandidate): boolean;
|
|
156
108
|
/**
|
|
157
109
|
* Computes the nearest exact `@khr3/c12` socket-snapped or ground-lattice `BuildSnapCandidate` for `kind`.
|
|
158
110
|
*/
|
|
159
111
|
export declare function computeBuildCandidate(placedPieces: readonly PlacedPiece[], aimPoint: readonly [number, number, number], kind: ToolgunBuildKind, yaw12: number, snapRadiusM?: number): BuildSnapCandidate;
|
|
160
112
|
export interface ToolgunStoreState {
|
|
161
113
|
readonly mode: ToolgunMode;
|
|
162
|
-
readonly skinPreset: ToolgunSkinPreset;
|
|
163
114
|
readonly yaw12: number;
|
|
164
115
|
readonly buildKind: ToolgunBuildKind;
|
|
165
116
|
readonly zoomed: boolean;
|
|
166
117
|
readonly armedAsset: ArmedToolgunAsset | null;
|
|
167
|
-
readonly target: ToolgunRayHit | null;
|
|
168
118
|
readonly buildPreview: BuildSnapCandidate | null;
|
|
169
119
|
readonly pendingAnchor: PendingJointAnchor | null;
|
|
170
120
|
readonly spawnedEntities: readonly SpawnedToolgunEntity[];
|
|
@@ -175,24 +125,24 @@ export interface ToolgunStoreState {
|
|
|
175
125
|
readonly fireCount: number;
|
|
176
126
|
setMode: (mode: ToolgunMode) => void;
|
|
177
127
|
cycleMode: (delta?: number) => void;
|
|
178
|
-
setSkinPreset: (preset: ToolgunSkinPreset) => void;
|
|
179
128
|
rotateYaw12: (stepsDelta?: number) => void;
|
|
180
129
|
setBuildKind: (kind: ToolgunBuildKind) => void;
|
|
181
130
|
cycleBuildKind: (delta?: number) => void;
|
|
182
131
|
setZoomed: (zoomed: boolean) => void;
|
|
183
132
|
armAsset: (asset: ArmedToolgunAsset | null) => void;
|
|
184
|
-
setTarget: (hit: ToolgunRayHit | null) => void;
|
|
185
133
|
setBuildPreview: (candidate: BuildSnapCandidate | null) => void;
|
|
186
134
|
setPendingAnchor: (anchor: PendingJointAnchor | null) => void;
|
|
187
135
|
recordSpawn: (entry: SpawnedToolgunEntity) => void;
|
|
188
136
|
placeBuildPiece: (candidate: BuildSnapCandidate) => PlacedPiece | null;
|
|
189
137
|
recordJoint: (entry: CreatedToolgunJoint) => void;
|
|
190
|
-
removeEntityById: (id: string) => boolean;
|
|
138
|
+
removeEntityById: (id: string, world?: RAPIER.World | null) => boolean;
|
|
191
139
|
removePieceById: (id: string) => boolean;
|
|
192
140
|
removeJointByBody: (world: RAPIER.World, body: RAPIER.RigidBody) => number;
|
|
141
|
+
clearWorldHandles: (world: RAPIER.World) => void;
|
|
193
142
|
undoLast: (world?: RAPIER.World | null) => string;
|
|
194
143
|
bumpFire: (status: string) => void;
|
|
195
144
|
resetAll: (world?: RAPIER.World | null) => void;
|
|
196
145
|
}
|
|
197
146
|
export declare function createToolgunStore(): UseBoundStore<StoreApi<ToolgunStoreState>>;
|
|
198
147
|
export declare const useToolgunStore: UseBoundStore<StoreApi<ToolgunStoreState>>;
|
|
148
|
+
export {};
|