@pinkaphant/kolmo 0.1.3 → 0.2.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 +3 -4
- package/bin/kolmo.mjs +9 -7
- package/dist/engine/kolmoActor.js +60 -59
- package/dist/engine/kolmoInput.d.ts +6 -1
- package/dist/engine/kolmoInput.js +72 -22
- package/dist/engine/kolmoLongDrive.js +52 -52
- package/dist/engine/kolmoVehicle.d.ts +2 -1
- package/dist/engine/kolmoVehicle.js +110 -103
- package/dist/engine/kolmoVehicleDriver.js +19 -28
- package/dist/engine/kolmoWorld.js +57 -54
- package/dist/engine/shiftedFixedBody.js +12 -28
- package/dist/importer/DomainWorkshopPanel.js +97 -98
- package/dist/importer/ImperativeVehicleRig.js +1 -3
- package/dist/importer/khrCompiler.js +0 -2
- package/dist/importer/universalGateBake.js +1 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +21 -24
- package/dist/junk/DestructibleTarget.js +1 -1
- package/dist/junk/targetHitLogic.js +0 -1
- package/dist/shaders/celestialBackdrop.d.ts +2 -2
- package/dist/shaders/celestialBackdrop.js +1 -1
- package/dist/shaders/plumeAndSparkle.d.ts +2 -2
- package/dist/shaders/plumeAndSparkle.js +4 -3
- package/dist/shaders/ps2RoadWebGL.js +1 -1
- package/dist/shaders/retroShader.d.ts +1 -1
- package/dist/shaders/retroShader.js +30 -14
- package/package.json +5 -9
- package/dist/body/HeldItem.d.ts +0 -22
- package/dist/body/HeldItem.js +0 -171
- package/dist/body/KhrBody.d.ts +0 -26
- package/dist/body/KhrBody.js +0 -179
- package/dist/body/bodySi.d.ts +0 -59
- package/dist/body/bodySi.js +0 -61
- package/dist/body/index.d.ts +0 -3
- package/dist/body/index.js +0 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { DecodedKolmoEmitter, KolmoSignalState } from "../schema/kolmoSchema.js";
|
|
3
|
-
export declare const PLUME_VERT = "\n uniform vec2 uPs1Grid; uniform float uSnapStrength, uTime, uThrottle, uBoost;\n varying vec2 vUv;\n void main() {\n vUv = uv; vec3 p = position; float along = clamp(uv.y, 0.0, 1.0);\n float shock = sin(along * 22.0 - uTime * (16.0 + uBoost * 24.0)) * (0.045 + uBoost * 0.085) * along;\n p.xz *= 1.0 + shock + along * (uThrottle * 0.25 + uBoost * 0.52);\n vec4 clip = projectionMatrix * modelViewMatrix * vec4(p, 1.0);\n \n if (uSnapStrength > 0.001 && clip.w > 0.001) {\n vec4 snapped = clip; snapped.xyz = clip.xyz / clip.w;\n
|
|
3
|
+
export declare const PLUME_VERT = "\n uniform vec2 uPs1Grid; uniform float uSnapStrength, uTime, uThrottle, uBoost;\n varying vec2 vUv;\n void main() {\n vUv = uv; vec3 p = position; float along = clamp(uv.y, 0.0, 1.0);\n float shock = sin(along * 22.0 - uTime * (16.0 + uBoost * 24.0)) * (0.045 + uBoost * 0.085) * along;\n p.xz *= 1.0 + shock + along * (uThrottle * 0.25 + uBoost * 0.52);\n vec4 clip = projectionMatrix * modelViewMatrix * vec4(p, 1.0);\n \n if (uSnapStrength > 0.001 && clip.w > 0.001) {\n vec4 snapped = clip; snapped.xyz = clip.xyz / clip.w;\n vec2 safeGrid = max(uPs1Grid * mix(2.5, 1.0, clamp(uSnapStrength, 0.0, 1.0)), vec2(1.0));\n snapped.xy = floor(safeGrid * snapped.xy + 0.5) / safeGrid;\n snapped.xyz *= clip.w; clip = snapped;\n }\n\n gl_Position = clip;\n }\n";
|
|
4
4
|
export declare const PLUME_FRAG = "\n uniform float uTime, uThrottle, uBoost, uIntensity, uDitherMix;\n uniform vec3 uColorCore, uColorMid, uColorOuter;\n varying vec2 vUv;\n \nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n\n void main() {\n float along = clamp(vUv.y, 0.0, 1.0);\n float tailFade = pow(1.0 - along, 1.15 - uBoost * 0.28), nozzleFade = smoothstep(0.0, 0.09, along);\n float throatHot = exp(-along * 5.2) * (0.65 + uThrottle * 0.55 + uBoost * 0.9);\n float machWave = sin(along * 28.0 - uTime * (16.0 + uThrottle * 10.0 + uBoost * 22.0)) * 0.5 + 0.5;\n float machCells = mix(machWave, step(0.42, machWave), uDitherMix * 0.85);\n float spiral = sin(vUv.x * 37.699 + along * 10.0 - uTime * 14.0) * 0.16 + 0.84;\n float density = (tailFade * (0.62 + machCells * 0.38) * spiral + throatHot * 0.45) * nozzleFade * uIntensity;\n if (density < mix(0.04, ps1Bayer4x4(gl_FragCoord.xy * 0.5) * 0.56 + 0.05, uDitherMix)) discard;\n vec3 cruise = mix(mix(uColorCore, uColorMid, smoothstep(0.05, 0.36, along)), uColorOuter, smoothstep(0.36, 0.88, along));\n vec3 boostC = mix(mix(vec3(1.0, 0.97, 0.90), vec3(0.18, 0.88, 1.0), smoothstep(0.04, 0.28, along)), vec3(1.0, 0.46, 0.08), smoothstep(0.28, 0.72, along));\n boostC += vec3(0.22, 0.52, 0.65) * machCells * (1.0 - along) * 0.45;\n vec3 col = mix(cruise, boostC, uBoost * 0.85) * (0.82 + uThrottle * 0.22 + uBoost * 0.28 + throatHot * 0.22);\n gl_FragColor = vec4(ps1QuantizeRGB555Mix(clamp(col, 0.0, 1.0), gl_FragCoord.xy, uDitherMix), clamp(mix(density * 0.88, 0.88, uDitherMix * 0.55), 0.16, 0.92));\n }\n";
|
|
5
|
-
export declare const PARTICLE_VERT = "\n attribute float aPhase, aAngle, aRadius, aSpeed, aSize;\n uniform float uTime, uDrive, uBoost, uScale, uMode, uSnapStrength;\n uniform vec2 uPs1Grid;\n varying float vLife, vBoost;\n void main() {\n float life = fract(aPhase + uTime * (0.7 + uDrive * 0.9 + uBoost * 1.4) * aSpeed);\n vLife = life; vBoost = uBoost;\n float coneLen = (1.35 + uDrive * 2.5 + uBoost * 4.4) * (uMode > 1.5 ? 1.55 : 1.0) * uScale;\n float z = -(0.04 * uScale + life * coneLen);\n float spread = uMode > 0.5 && uMode < 1.5 ? 1.6 : (uMode > 1.5 ? 0.42 : 0.88);\n float flare = aRadius * uScale * spread * (0.22 + life * (0.85 + uBoost * 0.95));\n float ang = aAngle + life * (3.2 + uBoost * 4.2) - uTime * 2.9;\n float rise = (uMode > 0.5 && uMode < 1.5) ? life * life * 0.52 * uScale : 0.0;\n vec4 mvPos = modelViewMatrix * vec4(cos(ang) * flare, sin(ang) * flare + rise, z, 1.0);\n vec4 clip = projectionMatrix * mvPos;\n \n if (uSnapStrength > 0.001 && clip.w > 0.001) {\n vec4 snapped = clip; snapped.xyz = clip.xyz / clip.w;\n
|
|
5
|
+
export declare const PARTICLE_VERT = "\n attribute float aPhase, aAngle, aRadius, aSpeed, aSize;\n uniform float uTime, uDrive, uBoost, uScale, uMode, uSnapStrength;\n uniform vec2 uPs1Grid;\n varying float vLife, vBoost;\n void main() {\n float life = fract(aPhase + uTime * (0.7 + uDrive * 0.9 + uBoost * 1.4) * aSpeed);\n vLife = life; vBoost = uBoost;\n float coneLen = (1.35 + uDrive * 2.5 + uBoost * 4.4) * (uMode > 1.5 ? 1.55 : 1.0) * uScale;\n float z = -(0.04 * uScale + life * coneLen);\n float spread = uMode > 0.5 && uMode < 1.5 ? 1.6 : (uMode > 1.5 ? 0.42 : 0.88);\n float flare = aRadius * uScale * spread * (0.22 + life * (0.85 + uBoost * 0.95));\n float ang = aAngle + life * (3.2 + uBoost * 4.2) - uTime * 2.9;\n float rise = (uMode > 0.5 && uMode < 1.5) ? life * life * 0.52 * uScale : 0.0;\n vec4 mvPos = modelViewMatrix * vec4(cos(ang) * flare, sin(ang) * flare + rise, z, 1.0);\n vec4 clip = projectionMatrix * mvPos;\n \n if (uSnapStrength > 0.001 && clip.w > 0.001) {\n vec4 snapped = clip; snapped.xyz = clip.xyz / clip.w;\n vec2 safeGrid = max(uPs1Grid * mix(2.5, 1.0, clamp(uSnapStrength, 0.0, 1.0)), vec2(1.0));\n snapped.xy = floor(safeGrid * snapped.xy + 0.5) / safeGrid;\n snapped.xyz *= clip.w; clip = snapped;\n }\n\n gl_Position = clip;\n float szMul = uMode > 0.5 && uMode < 1.5 ? (0.75 + life * 0.95) : (1.0 - life * 0.65);\n gl_PointSize = clamp(aSize * uScale * szMul * (0.65 + uDrive * 0.5 + uBoost * 0.9) * (155.0 / max(1.5, -mvPos.z)), 2.0, 26.0);\n }\n";
|
|
6
6
|
export declare const PARTICLE_FRAG = "\n uniform float uDitherMix, uMode;\n uniform vec3 uColor;\n varying float vLife, vBoost;\n \nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n\n void main() {\n vec2 p = abs(gl_PointCoord - 0.5) * 2.0;\n float manhattan = p.x + p.y;\n if (manhattan > 1.05) discard;\n float fade = (1.0 - vLife) * (1.0 - vLife * 0.35);\n if (uMode > 0.5 && uMode < 1.5) {\n if (fade < ps1Bayer4x4(gl_FragCoord.xy * 0.5) * 0.75 * uDitherMix) discard;\n gl_FragColor = vec4(ps1QuantizeRGB555Mix(mix(uColor * 1.1, uColor * 0.45, vLife), gl_FragCoord.xy, uDitherMix), clamp(fade * 0.68, 0.0, 0.8));\n return;\n }\n float core = 1.0 - smoothstep(0.0, 1.05, manhattan);\n vec3 cEnd = uMode > 1.5 ? uColor * 0.55 : mix(uColor * 0.7, vec3(1.0, 0.48, 0.1), 0.55 + vBoost * 0.45);\n vec3 col = mix(mix(vec3(0.96, 0.99, 1.0), uColor, smoothstep(0.0, 0.32, vLife)), cEnd, smoothstep(0.32, 0.95, vLife));\n col *= 1.05 + vBoost * 0.85 + core * 0.5;\n gl_FragColor = vec4(ps1QuantizeRGB555Mix(clamp(col, 0.0, 1.0), gl_FragCoord.xy, uDitherMix), clamp(fade * 0.9, 0.0, 0.95));\n }\n";
|
|
7
7
|
export interface KolmoEmitterRigProps {
|
|
8
8
|
emitters: readonly DecodedKolmoEmitter[];
|
|
@@ -8,7 +8,7 @@ var u = 48, d = [
|
|
|
8
8
|
0,
|
|
9
9
|
0,
|
|
10
10
|
0
|
|
11
|
-
], f = "\n if (uSnapStrength > 0.001 && clip.w > 0.001) {\n vec4 snapped = clip; snapped.xyz = clip.xyz / clip.w;\n
|
|
11
|
+
], f = "\n if (uSnapStrength > 0.001 && clip.w > 0.001) {\n vec4 snapped = clip; snapped.xyz = clip.xyz / clip.w;\n vec2 safeGrid = max(uPs1Grid * mix(2.5, 1.0, clamp(uSnapStrength, 0.0, 1.0)), vec2(1.0));\n snapped.xy = floor(safeGrid * snapped.xy + 0.5) / safeGrid;\n snapped.xyz *= clip.w; clip = snapped;\n }\n", p = `
|
|
12
12
|
uniform vec2 uPs1Grid; uniform float uSnapStrength, uTime, uThrottle, uBoost;
|
|
13
13
|
varying vec2 vUv;
|
|
14
14
|
void main() {
|
|
@@ -192,8 +192,9 @@ function x({ e, signalsRef: u }) {
|
|
|
192
192
|
if (x.current.visible = o > .015, !x.current.visible) return;
|
|
193
193
|
T.pts.uniforms.uTime.value += r, T.pts.uniforms.uDrive.value = o, T.pts.uniforms.uBoost.value = s;
|
|
194
194
|
} else if (T.halo && T.core && S.current) {
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
C.current += r;
|
|
196
|
+
let t = o * ((e.drive === "turn_l" || e.drive === "turn_r") && o > .5 ? Math.sin(C.current * 18) > -.1 ? 1 : .06 : 1);
|
|
197
|
+
S.current.visible = t > .02, S.current.scale.setScalar(e.size * (.65 + t * .75)), T.halo.opacity = t * .78, T.core.opacity = Math.min(1, t * .96), w.current && (w.current.emissiveIntensity = .15 + t * 2.4);
|
|
197
198
|
}
|
|
198
199
|
}), /* @__PURE__ */ l("group", {
|
|
199
200
|
position: e.localPosition,
|
|
@@ -14,7 +14,7 @@ function r(r, i) {
|
|
|
14
14
|
uPs2ColorQuantize: { value: i.ps2ColorQuantize ?? .85 },
|
|
15
15
|
uScreenPixelScale: { value: i.screenPixelScale ?? 1 }
|
|
16
16
|
}, s = new n.MeshLambertMaterial({
|
|
17
|
-
vertexColors: !
|
|
17
|
+
vertexColors: !1,
|
|
18
18
|
fog: !0,
|
|
19
19
|
polygonOffset: !0,
|
|
20
20
|
polygonOffsetFactor: -1,
|
|
@@ -86,7 +86,7 @@ export declare function syncRetroUniforms(presetId: RetroPresetId): RetroPreset;
|
|
|
86
86
|
export declare function syncRetroUniforms(ditherAmount: number, pixelSnapAmount?: number, renderScale?: number, colorMode?: RetroColorMode, ditherScale?: number, affineAmount?: number, gouraudAmount?: number, n64FilterAmount?: number): void;
|
|
87
87
|
export declare function syncRetroViewport(fbW: number, fbH: number, effectiveDpr: number): void;
|
|
88
88
|
export declare const GLSL_BAYER_RGB555 = "\nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n";
|
|
89
|
-
export declare const GLSL_RETRO_QUANTIZE = "\nuniform float uDitherScale; uniform vec4 uColorQuant; uniform sampler2D uPaletteLut;\n\nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n\nfloat ps1BayerDither(vec2 fragCoord) { return ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)); }\nvec3 ps1SamplePaletteLut(vec3 srgb) {\n vec3 c = clamp(srgb, 0.0, 1.0);\n return texture2D(uPaletteLut, vec2((floor(c.b * 31.0 + 0.5) * 32.0 + floor(c.r * 31.0 + 0.5) + 0.5) / 1024.0, (floor(c.g * 31.0 + 0.5) + 0.5) / 32.0)).rgb;\n}\nvec3 ps1QuantizeRetro(vec3 col, vec2 fragCoord, float ditherSpread) {\n if (uColorQuant.w < 0.5) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)), spread = clamp(ditherSpread, 0.0, 1.0);\n if (uColorQuant.w > 1.5) return ps1SamplePaletteLut(ps1LinearToSrgb(clamp(ps1SrgbToLinear(srgb) + (bayer - 0.5) * (uColorQuant.y * spread), 0.0, 1.0)));\n vec3 levels = max(uColorQuant.rgb, vec3(1.0)), c0 = floor(srgb * levels) / levels, c1 = min(c0 + 1.0 / levels, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, spread)), t));\n}\nvec4 ps1SampleN64ThreePoint(sampler2D tex, vec2 uv, float texSize, float mixStrength) {\n vec4 nearestSample = texture2D(tex, uv);\n if (mixStrength <= 0.001) return nearestSample;\n
|
|
89
|
+
export declare const GLSL_RETRO_QUANTIZE = "\nuniform float uDitherScale; uniform vec4 uColorQuant; uniform sampler2D uPaletteLut;\n\nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n\nfloat ps1BayerDither(vec2 fragCoord) { return ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)); }\nvec3 ps1SamplePaletteLut(vec3 srgb) {\n vec3 c = clamp(srgb, 0.0, 1.0);\n return texture2D(uPaletteLut, vec2((floor(c.b * 31.0 + 0.5) * 32.0 + floor(c.r * 31.0 + 0.5) + 0.5) / 1024.0, (floor(c.g * 31.0 + 0.5) + 0.5) / 32.0)).rgb;\n}\nvec3 ps1QuantizeRetro(vec3 col, vec2 fragCoord, float ditherSpread) {\n if (uColorQuant.w < 0.5) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)), spread = clamp(ditherSpread, 0.0, 1.0);\n if (uColorQuant.w > 1.5) return ps1SamplePaletteLut(ps1LinearToSrgb(clamp(ps1SrgbToLinear(srgb) + (bayer - 0.5) * (uColorQuant.y * spread), 0.0, 1.0)));\n vec3 levels = max(uColorQuant.rgb, vec3(1.0)), c0 = floor(srgb * levels) / levels, c1 = min(c0 + 1.0 / levels, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, spread)), t));\n}\nvec4 ps1SampleN64ThreePoint(sampler2D tex, vec2 uv, float texSize, float mixStrength) {\n vec4 nearestSample = texture2D(tex, uv);\n if (mixStrength <= 0.001) return nearestSample;\n #if __VERSION__ >= 300\n vec2 ts = max(vec2(textureSize(tex, 0)), vec2(16.0));\n #else\n vec2 ts = vec2(max(16.0, texSize));\n #endif\n vec2 p = uv * ts - 0.5;\n vec2 i = floor(p);\n vec2 f = p - i;\n vec2 inv = 1.0 / ts;\n vec2 uv00 = (i + vec2(0.5, 0.5)) * inv;\n vec2 uv10 = (i + vec2(1.5, 0.5)) * inv;\n vec2 uv01 = (i + vec2(0.5, 1.5)) * inv;\n vec2 uv11 = (i + vec2(1.5, 1.5)) * inv;\n vec4 c10 = texture2D(tex, uv10);\n vec4 c01 = texture2D(tex, uv01);\n vec4 n64Col;\n if (f.x + f.y < 1.0) {\n vec4 c00 = texture2D(tex, uv00);\n n64Col = c00 + f.x * (c10 - c00) + f.y * (c01 - c00);\n } else {\n vec4 c11 = texture2D(tex, uv11);\n n64Col = c11 + (1.0 - f.y) * (c10 - c11) + (1.0 - f.x) * (c01 - c11);\n }\n return mix(nearestSample, n64Col, clamp(mixStrength, 0.0, 1.0));\n}\nfloat ps1ProcTexelHash(vec2 cell) {\n return fract(sin(dot(cell, vec2(127.1, 311.7))) * 43758.5453);\n}\nfloat ps1ProcN64ThreePoint(vec2 uv, float mixStrength) {\n vec2 p = uv * 8.0 - 0.5;\n vec2 i = floor(p);\n vec2 f = p - i;\n float nearestVal = ps1ProcTexelHash(floor(uv * 8.0));\n if (mixStrength <= 0.001) return nearestVal;\n float c10 = ps1ProcTexelHash(i + vec2(1.0, 0.0));\n float c01 = ps1ProcTexelHash(i + vec2(0.0, 1.0));\n float n64Val;\n if (f.x + f.y < 1.0) {\n float c00 = ps1ProcTexelHash(i);\n n64Val = c00 + f.x * (c10 - c00) + f.y * (c01 - c00);\n } else {\n float c11 = ps1ProcTexelHash(i + vec2(1.0, 1.0));\n n64Val = c11 + (1.0 - f.y) * (c10 - c11) + (1.0 - f.x) * (c01 - c11);\n }\n return mix(nearestVal, n64Val, clamp(mixStrength, 0.0, 1.0));\n}\n";
|
|
90
90
|
export interface RetroMaterialOptions {
|
|
91
91
|
flatShading?: boolean;
|
|
92
92
|
snap?: number;
|
|
@@ -198,11 +198,15 @@ vec3 ps1QuantizeRetro(vec3 col, vec2 fragCoord, float ditherSpread) {
|
|
|
198
198
|
vec4 ps1SampleN64ThreePoint(sampler2D tex, vec2 uv, float texSize, float mixStrength) {
|
|
199
199
|
vec4 nearestSample = texture2D(tex, uv);
|
|
200
200
|
if (mixStrength <= 0.001) return nearestSample;
|
|
201
|
-
|
|
201
|
+
#if __VERSION__ >= 300
|
|
202
|
+
vec2 ts = max(vec2(textureSize(tex, 0)), vec2(16.0));
|
|
203
|
+
#else
|
|
204
|
+
vec2 ts = vec2(max(16.0, texSize));
|
|
205
|
+
#endif
|
|
202
206
|
vec2 p = uv * ts - 0.5;
|
|
203
207
|
vec2 i = floor(p);
|
|
204
208
|
vec2 f = p - i;
|
|
205
|
-
vec2 inv = 1.0 /
|
|
209
|
+
vec2 inv = 1.0 / ts;
|
|
206
210
|
vec2 uv00 = (i + vec2(0.5, 0.5)) * inv;
|
|
207
211
|
vec2 uv10 = (i + vec2(1.5, 0.5)) * inv;
|
|
208
212
|
vec2 uv01 = (i + vec2(0.5, 1.5)) * inv;
|
|
@@ -219,24 +223,36 @@ vec4 ps1SampleN64ThreePoint(sampler2D tex, vec2 uv, float texSize, float mixStre
|
|
|
219
223
|
}
|
|
220
224
|
return mix(nearestSample, n64Col, clamp(mixStrength, 0.0, 1.0));
|
|
221
225
|
}
|
|
226
|
+
float ps1ProcTexelHash(vec2 cell) {
|
|
227
|
+
return fract(sin(dot(cell, vec2(127.1, 311.7))) * 43758.5453);
|
|
228
|
+
}
|
|
229
|
+
float ps1ProcN64ThreePoint(vec2 uv, float mixStrength) {
|
|
230
|
+
vec2 p = uv * 8.0 - 0.5;
|
|
231
|
+
vec2 i = floor(p);
|
|
232
|
+
vec2 f = p - i;
|
|
233
|
+
float nearestVal = ps1ProcTexelHash(floor(uv * 8.0));
|
|
234
|
+
if (mixStrength <= 0.001) return nearestVal;
|
|
235
|
+
float c10 = ps1ProcTexelHash(i + vec2(1.0, 0.0));
|
|
236
|
+
float c01 = ps1ProcTexelHash(i + vec2(0.0, 1.0));
|
|
237
|
+
float n64Val;
|
|
238
|
+
if (f.x + f.y < 1.0) {
|
|
239
|
+
float c00 = ps1ProcTexelHash(i);
|
|
240
|
+
n64Val = c00 + f.x * (c10 - c00) + f.y * (c01 - c00);
|
|
241
|
+
} else {
|
|
242
|
+
float c11 = ps1ProcTexelHash(i + vec2(1.0, 1.0));
|
|
243
|
+
n64Val = c11 + (1.0 - f.y) * (c10 - c11) + (1.0 - f.x) * (c01 - c11);
|
|
244
|
+
}
|
|
245
|
+
return mix(nearestVal, n64Val, clamp(mixStrength, 0.0, 1.0));
|
|
246
|
+
}
|
|
222
247
|
`, T = /* @__PURE__ */ new WeakSet();
|
|
223
248
|
function E(e, t) {
|
|
224
249
|
if (!e || T.has(e)) return e;
|
|
225
250
|
T.add(e), e.userData.__kolmoRetroApplied = !0, t?.flatShading !== !1 && "flatShading" in e && (e.flatShading = !0);
|
|
226
251
|
let n = e.onBeforeCompile, r = Object.prototype.hasOwnProperty.call(e, "customProgramCacheKey") ? e.customProgramCacheKey : null, i = t?.snap === void 0 ? d.uSnapStrength : { value: t.snap }, a = t?.dither === void 0 ? d.uDitherMix : { value: t.dither };
|
|
227
252
|
return e.onBeforeCompile = (t, r) => {
|
|
228
|
-
n && n.call(e, t, r),
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
uDitherMix: a,
|
|
232
|
-
uDitherScale: d.uDitherScale,
|
|
233
|
-
uColorQuant: d.uColorQuant,
|
|
234
|
-
uPaletteLut: d.uPaletteLut,
|
|
235
|
-
uAffineStrength: d.uAffineStrength,
|
|
236
|
-
uGouraudStrength: d.uGouraudStrength,
|
|
237
|
-
uN64FilterStrength: d.uN64FilterStrength,
|
|
238
|
-
uN64TexSize: d.uN64TexSize
|
|
239
|
-
}), t.vertexShader = "uniform vec2 uPs1Grid;\nuniform float uSnapStrength;\nuniform float uAffineStrength;\nuniform float uGouraudStrength;\nvarying float vRetroAffineW;\nvarying vec3 vRetroGouraud;\n" + t.vertexShader.replace("#include <project_vertex>", "#include <project_vertex>\n{\n vRetroAffineW = 1.0;\n vRetroGouraud = vec3(1.0);\n if (uSnapStrength > 0.001 && gl_Position.w > 0.001) {\n vec4 snapped = gl_Position; snapped.xyz = gl_Position.xyz / gl_Position.w;\n vec2 ps1SafeGrid = max(uPs1Grid, vec2(1.0));\n snapped.xy = mix(snapped.xy, floor(ps1SafeGrid * snapped.xy + 0.5) / ps1SafeGrid, uSnapStrength);\n snapped.xyz *= gl_Position.w; gl_Position = snapped;\n }\n #ifdef USE_MAP\n if (uAffineStrength > 0.001 && gl_Position.w > 0.001) {\n float ps1W = mix(1.0, max(gl_Position.w, 0.05), uAffineStrength);\n vMapUv *= ps1W; vRetroAffineW = ps1W;\n }\n #endif\n #ifdef USE_NORMAL\n #ifndef FLAT_SHADED\n if (uGouraudStrength > 0.001) {\n vec3 gN = normalize(vNormal);\n vec3 gKey = normalize(vec3(-0.55, 0.72, 0.42));\n vec3 gRim = normalize(vec3(0.58, -0.25, -0.77));\n float gDiff = max(dot(gN, gKey), 0.0) * 0.78 + max(dot(gN, gRim), 0.0) * 0.28 + 0.26;\n float gSpec = pow(max(dot(reflect(-gKey, gN), vec3(0.0, 0.0, 1.0)), 0.0), 14.0) * 0.36;\n vRetroGouraud = mix(vec3(1.0), vec3(gDiff + gSpec), uGouraudStrength);\n }\n #endif\n #endif\n}"), t.fragmentShader = `uniform float uDitherMix;\nuniform float uAffineStrength;\nuniform float uGouraudStrength;\nuniform float uN64FilterStrength;\nuniform float uN64TexSize;\nvarying float vRetroAffineW;\nvarying vec3 vRetroGouraud;\n${w}\n` + t.fragmentShader.replace("#include <map_fragment>", "#ifdef USE_MAP\n{\n vec2 ps1Uv = (uAffineStrength > 0.001 && vRetroAffineW > 0.0001) ? (vMapUv / vRetroAffineW) : vMapUv;\n diffuseColor *= ps1SampleN64ThreePoint( map, ps1Uv, uN64TexSize, uN64FilterStrength );\n}\n#endif").replace("#include <dithering_fragment>", "gl_FragColor.rgb *= mix(vec3(1.0), vRetroGouraud, uGouraudStrength);\ngl_FragColor.rgb = ps1QuantizeRetro(gl_FragColor.rgb, gl_FragCoord.xy, uDitherMix);");
|
|
253
|
+
n && n.call(e, t, r), t.uniforms.uPs1Grid = d.uPs1Grid, t.uniforms.uSnapStrength = i, t.uniforms.uDitherMix = a, t.uniforms.uDitherScale = d.uDitherScale, t.uniforms.uColorQuant = d.uColorQuant, t.uniforms.uPaletteLut = d.uPaletteLut, t.uniforms.uAffineStrength = d.uAffineStrength, t.uniforms.uGouraudStrength = d.uGouraudStrength, t.uniforms.uN64FilterStrength = d.uN64FilterStrength, t.uniforms.uN64TexSize = d.uN64TexSize;
|
|
254
|
+
let o = t.vertexShader.includes("#include <defaultnormal_vertex>") || t.vertexShader.includes("transformedNormal"), s = t.vertexShader.includes("#include <begin_vertex>") || t.vertexShader.includes("transformed"), c = o ? " if (uGouraudStrength > 0.001) {\n vec3 gN = normalize(transformedNormal);\n vec3 gKey = normalize(vec3(-0.55, 0.72, 0.42));\n vec3 gRim = normalize(vec3(0.58, -0.25, -0.77));\n float gDiff = max(dot(gN, gKey), 0.0) * 0.85 + max(dot(gN, gRim), 0.0) * 0.30 + 0.18;\n float gSpec = pow(max(dot(reflect(-gKey, gN), vec3(0.0, 0.0, 1.0)), 0.0), 16.0) * 0.48;\n vRetroGouraud = mix(vec3(1.0), vec3(gDiff + gSpec), uGouraudStrength);\n }\n" : "", l = s ? " vRetroProcUv = vec2(transformed.x + transformed.z * 0.5, transformed.y + transformed.z * 0.5) * 0.5;\n if (uAffineStrength > 0.001 && gl_Position.w > 0.001) {\n float ps1ProcW = mix(1.0, max(gl_Position.w, 0.05), uAffineStrength);\n vRetroProcUv *= ps1ProcW; vRetroAffineW = ps1ProcW;\n }\n" : "";
|
|
255
|
+
t.vertexShader = "uniform vec2 uPs1Grid;\nuniform float uSnapStrength;\nuniform float uAffineStrength;\nuniform float uGouraudStrength;\nvarying float vRetroAffineW;\nvarying vec2 vRetroProcUv;\nvarying vec3 vRetroGouraud;\n" + t.vertexShader.replace("#include <project_vertex>", `#include <project_vertex>\n{\n vRetroAffineW = 1.0;\n vRetroProcUv = vec2(0.0);\n vRetroGouraud = vec3(1.0);\n if (uSnapStrength > 0.001 && gl_Position.w > 0.001) {\n vec4 snapped = gl_Position; snapped.xyz = gl_Position.xyz / gl_Position.w;\n vec2 ps1SafeGrid = max(uPs1Grid * mix(2.5, 1.0, clamp(uSnapStrength, 0.0, 1.0)), vec2(1.0));\n snapped.xy = floor(ps1SafeGrid * snapped.xy + 0.5) / ps1SafeGrid;\n snapped.xyz *= gl_Position.w; gl_Position = snapped;\n }\n${l} #ifdef USE_MAP\n if (uAffineStrength > 0.001 && gl_Position.w > 0.001) {\n float ps1W = mix(1.0, max(gl_Position.w, 0.05), uAffineStrength);\n vMapUv *= ps1W; vRetroAffineW = ps1W;\n }\n #endif\n${c}}`), t.fragmentShader = `uniform float uDitherMix;\nuniform float uAffineStrength;\nuniform float uGouraudStrength;\nuniform float uN64FilterStrength;\nuniform float uN64TexSize;\nvarying float vRetroAffineW;\nvarying vec2 vRetroProcUv;\nvarying vec3 vRetroGouraud;\n${w}\n` + t.fragmentShader.replace("#include <map_fragment>", "#ifdef USE_MAP\n{\n vec2 ps1Uv = (uAffineStrength > 0.001 && vRetroAffineW > 0.0001) ? (vMapUv / vRetroAffineW) : vMapUv;\n diffuseColor *= ps1SampleN64ThreePoint( map, ps1Uv, uN64TexSize, uN64FilterStrength );\n}\n#else\nif (uAffineStrength > 0.001 || uN64FilterStrength > 0.001) {\n vec2 ps1ProcUv = (uAffineStrength > 0.001 && vRetroAffineW > 0.0001) ? (vRetroProcUv / vRetroAffineW) : vRetroProcUv;\n float procGrain = ps1ProcN64ThreePoint(ps1ProcUv, uN64FilterStrength);\n diffuseColor.rgb *= mix(1.0, mix(0.86, 1.14, procGrain), max(uN64FilterStrength * 0.65, uAffineStrength * 0.85));\n}\n#endif").replace("#include <dithering_fragment>", "gl_FragColor.rgb *= mix(vec3(1.0), vRetroGouraud, uGouraudStrength);\ngl_FragColor.rgb = ps1QuantizeRetro(gl_FragColor.rgb, gl_FragCoord.xy, uDitherMix);");
|
|
240
256
|
}, e.customProgramCacheKey = () => r ? `${r.call(e)}_dream_nuschool_retro_v3` : "dream_nuschool_retro_v3", e.needsUpdate = !0, e;
|
|
241
257
|
}
|
|
242
258
|
var D = E;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinkaphant/kolmo",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -39,10 +39,6 @@
|
|
|
39
39
|
"types": "./dist/engine/index.d.ts",
|
|
40
40
|
"import": "./dist/engine/index.js"
|
|
41
41
|
},
|
|
42
|
-
"./body": {
|
|
43
|
-
"types": "./dist/body/index.d.ts",
|
|
44
|
-
"import": "./dist/body/index.js"
|
|
45
|
-
},
|
|
46
42
|
"./importer": {
|
|
47
43
|
"types": "./dist/importer/index.d.ts",
|
|
48
44
|
"import": "./dist/importer/index.js"
|
|
@@ -78,7 +74,7 @@
|
|
|
78
74
|
},
|
|
79
75
|
"peerDependencies": {
|
|
80
76
|
"@dimforge/rapier3d-compat": "0.19.2",
|
|
81
|
-
"@pinkaphant/ecctrl": "
|
|
77
|
+
"@pinkaphant/ecctrl": "2.0.4-beta.2",
|
|
82
78
|
"@react-three/drei": ">=10.7.0",
|
|
83
79
|
"@react-three/fiber": ">=9.6.0",
|
|
84
80
|
"@react-three/rapier": "^2.2.0",
|
|
@@ -90,9 +86,9 @@
|
|
|
90
86
|
"dependencies": {
|
|
91
87
|
"@khr3/assets": "^0.2.2",
|
|
92
88
|
"@khr3/c12": "^0.3.1",
|
|
93
|
-
"@khr3/core": "^0.1.
|
|
89
|
+
"@khr3/core": "^0.1.4",
|
|
94
90
|
"@khr3/launchers": "^0.2.2",
|
|
95
|
-
"@khr3/vehicles": "^0.1.
|
|
91
|
+
"@khr3/vehicles": "^0.1.4",
|
|
96
92
|
"@pmndrs/uikit": "^1.0.78",
|
|
97
93
|
"@preact/signals-core": "^1.14.5",
|
|
98
94
|
"@react-three/uikit": "^1.0.78",
|
|
@@ -101,7 +97,7 @@
|
|
|
101
97
|
},
|
|
102
98
|
"devDependencies": {
|
|
103
99
|
"@dimforge/rapier3d-compat": "0.19.2",
|
|
104
|
-
"@pinkaphant/ecctrl": "
|
|
100
|
+
"@pinkaphant/ecctrl": "2.0.4-beta.2",
|
|
105
101
|
"@react-three/drei": "^10.7.7",
|
|
106
102
|
"@react-three/fiber": "^9.6.1",
|
|
107
103
|
"@react-three/rapier": "^2.2.0",
|
package/dist/body/HeldItem.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type KhrAssetBundle } from "@khr3/core";
|
|
2
|
-
import { type RapierRigidBody } from "@react-three/rapier";
|
|
3
|
-
import { type Ref, type RefObject } from "react";
|
|
4
|
-
import * as THREE from "three";
|
|
5
|
-
import { type BodySocketId } from "./bodySi.js";
|
|
6
|
-
import type { KhrBodyHandle } from "./KhrBody.js";
|
|
7
|
-
export interface HeldItemHandle {
|
|
8
|
-
readonly socket: BodySocketId;
|
|
9
|
-
readonly rigidBody: RapierRigidBody | null;
|
|
10
|
-
setRoleTarget(role: string, target: number): number;
|
|
11
|
-
setJointTarget(nodeName: string, target: number): number;
|
|
12
|
-
getRoleValue(role: string): number;
|
|
13
|
-
}
|
|
14
|
-
export interface HeldItemProps {
|
|
15
|
-
readonly ref?: Ref<HeldItemHandle>;
|
|
16
|
-
readonly bundle: KhrAssetBundle;
|
|
17
|
-
readonly socket: BodySocketId;
|
|
18
|
-
readonly bodyRef?: RefObject<KhrBodyHandle | null>;
|
|
19
|
-
readonly parentSocketObject?: THREE.Object3D | null;
|
|
20
|
-
readonly userData?: Record<string, unknown>;
|
|
21
|
-
}
|
|
22
|
-
export declare function HeldItem({ ref, bundle, socket, bodyRef, parentSocketObject, userData }: HeldItemProps): import("react").JSX.Element;
|
package/dist/body/HeldItem.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { withExcludeCharacterRay as e } from "./bodySi.js";
|
|
2
|
-
import { useCallback as t, useContext as n, useImperativeHandle as r, useLayoutEffect as i, useMemo as a, useRef as o } from "react";
|
|
3
|
-
import * as s from "three";
|
|
4
|
-
import { useFrame as c } from "@react-three/fiber";
|
|
5
|
-
import { JointRegistryContext as l, KhrCollider as u, KhrValidationError as d, claimBundleMount as f, releaseBundleMount as p } from "@khr3/core";
|
|
6
|
-
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
7
|
-
import { RigidBody as _, useRapier as v } from "@react-three/rapier";
|
|
8
|
-
// src/body/HeldItem.tsx
|
|
9
|
-
var y = new s.Vector3(), b = new s.Vector3(), x = new s.Quaternion(), S = new s.Matrix4(), C = new s.Vector3(), w = new s.Quaternion(), T = new s.Vector3(), E = 1e5;
|
|
10
|
-
function D(e, t) {
|
|
11
|
-
if (t.kind === "fixed") return 0;
|
|
12
|
-
if (t.kind === "prismatic") {
|
|
13
|
-
if (!(e.mass > 0)) throw new d(`kolmo/body: Prismatic joint "${e.nodeName}" requires positive mass, got ${e.mass}`);
|
|
14
|
-
return e.mass;
|
|
15
|
-
}
|
|
16
|
-
y.fromArray(t.axis).normalize(), x.fromArray(e.inertiaOrientation).invert();
|
|
17
|
-
let n = y.clone().applyQuaternion(x), [r, i, a] = e.inertiaDiagonal, o = r * n.x * n.x + i * n.y * n.y + a * n.z * n.z;
|
|
18
|
-
b.fromArray(e.centerOfMass);
|
|
19
|
-
let s = b.dot(y), c = o + e.mass * (b.lengthSq() - s * s);
|
|
20
|
-
if (!(c > 0)) throw new d(`kolmo/body: Revolute joint "${e.nodeName}" requires positive inertia, got ${c}`);
|
|
21
|
-
return c;
|
|
22
|
-
}
|
|
23
|
-
var O = (e) => new s.Matrix4().compose(new s.Vector3().fromArray(e.localPosition), new s.Quaternion().fromArray(e.localQuaternion), new s.Vector3(1, 1, 1));
|
|
24
|
-
function k({ ref: y, bundle: b, socket: x, bodyRef: k, parentSocketObject: A, userData: j }) {
|
|
25
|
-
let { world: M } = v(), N = n(l), P = a(() => E++, []), F = o(null), I = o(null), L = o(/* @__PURE__ */ new Map()), R = a(() => e(j), [j]), { rootPose: z, invRoot: B, colliderEntries: V } = a(() => {
|
|
26
|
-
let e = b.bodies.find((e) => !e.joint) ?? b.bodies[0], t = e ? O(e) : new s.Matrix4(), n = t.clone().invert(), r = new s.Vector3(), i = new s.Quaternion(), a = new s.Vector3(), o = [];
|
|
27
|
-
for (let e of b.bodies) {
|
|
28
|
-
let t = n.clone().multiply(O(e));
|
|
29
|
-
for (let n = 0; n < e.colliders.length; n++) {
|
|
30
|
-
let c = e.colliders[n], l = new s.Matrix4().compose(new s.Vector3().fromArray(c.localPosition), new s.Quaternion().fromArray(c.localQuaternion), new s.Vector3(1, 1, 1));
|
|
31
|
-
t.clone().multiply(l).decompose(r, i, a), i.normalize(), o.push({
|
|
32
|
-
key: `${e.nodeName}:${n}`,
|
|
33
|
-
nodeName: e.nodeName,
|
|
34
|
-
spec: c,
|
|
35
|
-
local: l,
|
|
36
|
-
restPos: [
|
|
37
|
-
r.x,
|
|
38
|
-
r.y,
|
|
39
|
-
r.z
|
|
40
|
-
],
|
|
41
|
-
restQuat: [
|
|
42
|
-
i.x,
|
|
43
|
-
i.y,
|
|
44
|
-
i.z,
|
|
45
|
-
i.w
|
|
46
|
-
],
|
|
47
|
-
ref: { current: null }
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
rootPose: t,
|
|
53
|
-
invRoot: n,
|
|
54
|
-
colliderEntries: o
|
|
55
|
-
};
|
|
56
|
-
}, [b]), H = t(() => {
|
|
57
|
-
let e = F.current, t = A ?? k?.current?.socket(x) ?? I.current;
|
|
58
|
-
e && t && (b.scene.parent !== t && t.add(b.scene), b.scene.updateWorldMatrix(!0, !1), S.multiplyMatrices(b.scene.matrixWorld, z), S.decompose(C, w, T), w.normalize(), e.setTranslation(C, !0), e.setRotation(w, !0), e.setNextKinematicTranslation(C), e.setNextKinematicRotation(w), M.propagateModifiedBodyPositionsToColliders());
|
|
59
|
-
}, [
|
|
60
|
-
b,
|
|
61
|
-
z,
|
|
62
|
-
A,
|
|
63
|
-
k,
|
|
64
|
-
x,
|
|
65
|
-
M
|
|
66
|
-
]);
|
|
67
|
-
return i(() => {
|
|
68
|
-
f(b, "HeldItem");
|
|
69
|
-
let e = b.scene.position.clone(), t = b.scene.quaternion.clone(), n = b.scene.parent, r = b.sockets.grip_primary ?? b.sockets.IK_Palm_Primary;
|
|
70
|
-
r ? b.scene.position.set(-r[0], -r[1], -r[2]) : b.scene.position.set(0, 0, 0);
|
|
71
|
-
let i = A ?? k?.current?.socket(x) ?? I.current;
|
|
72
|
-
i && b.scene.parent !== i && i.add(b.scene);
|
|
73
|
-
let a = new Map(b.bodies.map((e) => [e.nodeName, e])), o = /* @__PURE__ */ new Map();
|
|
74
|
-
for (let e of b.bodies) {
|
|
75
|
-
let t = e.joint;
|
|
76
|
-
if (!t) continue;
|
|
77
|
-
let n = a.get(t.connectedNodeName), r = B.clone().multiply(O(e)), i = n?.joint ? O(n).invert().multiply(O(e)) : r, c = V.filter((t) => t.nodeName === e.nodeName).map((e) => ({
|
|
78
|
-
ref: e.ref,
|
|
79
|
-
local: e.local
|
|
80
|
-
})), l = t.drive;
|
|
81
|
-
o.set(e.nodeName, {
|
|
82
|
-
assemblyId: P,
|
|
83
|
-
nodeName: e.nodeName,
|
|
84
|
-
role: t.role ?? e.role,
|
|
85
|
-
kind: t.kind,
|
|
86
|
-
object: e.object,
|
|
87
|
-
axis: new s.Vector3().fromArray(t.axis).normalize(),
|
|
88
|
-
restPosition: e.object.position.clone(),
|
|
89
|
-
restQuaternion: e.object.quaternion.clone(),
|
|
90
|
-
q: 0,
|
|
91
|
-
v: 0,
|
|
92
|
-
positionTarget: l?.positionTarget ?? null,
|
|
93
|
-
velocityTarget: l?.velocityTarget ?? 0,
|
|
94
|
-
drive: l,
|
|
95
|
-
limits: t.limits ? [t.limits[0], t.limits[1]] : null,
|
|
96
|
-
limitStiffness: t.limitStiffness ?? null,
|
|
97
|
-
limitDamping: t.limitDamping ?? 0,
|
|
98
|
-
inertia: D(e, t),
|
|
99
|
-
parent: null,
|
|
100
|
-
restRelParent: i,
|
|
101
|
-
current: i.clone(),
|
|
102
|
-
stamp: -1,
|
|
103
|
-
colliders: c
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
for (let e of b.bodies) {
|
|
107
|
-
if (!e.joint) continue;
|
|
108
|
-
let t = o.get(e.nodeName);
|
|
109
|
-
t.parent = o.get(e.joint.connectedNodeName) ?? null, N?.add(t);
|
|
110
|
-
}
|
|
111
|
-
return L.current = o, H(), () => {
|
|
112
|
-
for (let e of o.values()) N?.delete(e), e.object.position.copy(e.restPosition), e.object.quaternion.copy(e.restQuaternion);
|
|
113
|
-
L.current = /* @__PURE__ */ new Map(), b.scene.parent && b.scene.parent.remove(b.scene), n && n.add(b.scene), b.scene.position.copy(e), b.scene.quaternion.copy(t), p(b);
|
|
114
|
-
};
|
|
115
|
-
}, [
|
|
116
|
-
b,
|
|
117
|
-
x,
|
|
118
|
-
k,
|
|
119
|
-
A,
|
|
120
|
-
N,
|
|
121
|
-
P,
|
|
122
|
-
B,
|
|
123
|
-
V,
|
|
124
|
-
H
|
|
125
|
-
]), c(() => {
|
|
126
|
-
H();
|
|
127
|
-
}), r(y, () => {
|
|
128
|
-
let e = (e, t) => {
|
|
129
|
-
if (!e.drive || e.drive.stiffness === void 0) throw new d(`Joint "${e.nodeName}" has no authored drive stiffness; cannot set a position target`);
|
|
130
|
-
let n = e.limits ? Math.max(e.limits[0], Math.min(e.limits[1], t)) : t;
|
|
131
|
-
return e.positionTarget = n, n;
|
|
132
|
-
};
|
|
133
|
-
return {
|
|
134
|
-
socket: x,
|
|
135
|
-
get rigidBody() {
|
|
136
|
-
return F.current;
|
|
137
|
-
},
|
|
138
|
-
setJointTarget(t, n) {
|
|
139
|
-
let r = L.current.get(t);
|
|
140
|
-
if (!r) throw new d(`kolmo/body: HeldItem has no joint named "${t}"`);
|
|
141
|
-
return e(r, n);
|
|
142
|
-
},
|
|
143
|
-
setRoleTarget(t, n) {
|
|
144
|
-
let r = !1, i = n;
|
|
145
|
-
for (let a of L.current.values()) a.role === t && (i = e(a, n), r = !0);
|
|
146
|
-
if (!r) throw new d(`kolmo/body: HeldItem has no joint with role "${t}"`);
|
|
147
|
-
return i;
|
|
148
|
-
},
|
|
149
|
-
getRoleValue(e) {
|
|
150
|
-
for (let t of L.current.values()) if (t.role === e) return t.q;
|
|
151
|
-
throw new d(`kolmo/body: HeldItem has no joint with role "${e}"`);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}, [x]), /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("group", {
|
|
155
|
-
ref: I,
|
|
156
|
-
name: `HeldItem_Fallback_${x}`
|
|
157
|
-
}), /* @__PURE__ */ h(_, {
|
|
158
|
-
ref: F,
|
|
159
|
-
type: "kinematicPosition",
|
|
160
|
-
colliders: !1,
|
|
161
|
-
sensor: !0,
|
|
162
|
-
userData: R,
|
|
163
|
-
children: V.map((e) => /* @__PURE__ */ h(u, {
|
|
164
|
-
ref: e.ref,
|
|
165
|
-
c: e.spec,
|
|
166
|
-
position: e.restPos,
|
|
167
|
-
quaternion: e.restQuat
|
|
168
|
-
}, e.key))
|
|
169
|
-
})] });
|
|
170
|
-
}
|
|
171
|
-
export { k as HeldItem };
|
package/dist/body/KhrBody.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type EcctrlHandle, type EcctrlProps } from "@pinkaphant/ecctrl";
|
|
2
|
-
import { type EcctrlCameraControlsHandle } from "@pinkaphant/ecctrl/camera";
|
|
3
|
-
import { type ReactNode, type Ref } from "react";
|
|
4
|
-
import * as THREE from "three";
|
|
5
|
-
import { stepCameraSync, type BodySiConstants, type BodySocketId } from "./bodySi.js";
|
|
6
|
-
export { stepCameraSync };
|
|
7
|
-
export interface KhrBodyHandle {
|
|
8
|
-
readonly ecctrl: EcctrlHandle | null;
|
|
9
|
-
readonly cameraControls: EcctrlCameraControlsHandle | null;
|
|
10
|
-
socket(id: BodySocketId): THREE.Object3D | null;
|
|
11
|
-
syncCameraStep(pos: {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
z: number;
|
|
15
|
-
}): void;
|
|
16
|
-
}
|
|
17
|
-
export interface KhrBodyProps extends Omit<EcctrlProps, "ref"> {
|
|
18
|
-
readonly ref?: Ref<KhrBodyHandle>;
|
|
19
|
-
readonly si?: BodySiConstants;
|
|
20
|
-
readonly smoothCamera?: boolean;
|
|
21
|
-
readonly makeDefaultCamera?: boolean;
|
|
22
|
-
readonly enableInput?: boolean;
|
|
23
|
-
readonly viewModelChildren?: ReactNode;
|
|
24
|
-
readonly socketOffsets?: Partial<Record<BodySocketId, readonly [number, number, number]>>;
|
|
25
|
-
}
|
|
26
|
-
export declare function KhrBody({ ref, si, smoothCamera, makeDefaultCamera, enableInput, enable, viewModelChildren, socketOffsets, children, userData: callerUserData, position, ...ecctrlProps }: KhrBodyProps): import("react").JSX.Element;
|
package/dist/body/KhrBody.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { BODY_MOVE_TUNE as e, BODY_SI as t, BODY_SOCKET_IDS as n, bodyEyeOffsetY as r, bodyRestCenterY as i, stepCameraSync as a } from "./bodySi.js";
|
|
2
|
-
import { useEffect as o, useImperativeHandle as s, useMemo as c, useRef as l } from "react";
|
|
3
|
-
import { useFrame as u, useThree as d } from "@react-three/fiber";
|
|
4
|
-
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
5
|
-
import { Ecctrl as h } from "@pinkaphant/ecctrl";
|
|
6
|
-
import { EcctrlCameraControls as g } from "@pinkaphant/ecctrl/camera";
|
|
7
|
-
// src/body/KhrBody.tsx
|
|
8
|
-
var _ = Object.freeze({
|
|
9
|
-
Socket_Hand_R: [
|
|
10
|
-
.22,
|
|
11
|
-
-.18,
|
|
12
|
-
-.38
|
|
13
|
-
],
|
|
14
|
-
Socket_Hand_L: [
|
|
15
|
-
-.22,
|
|
16
|
-
-.18,
|
|
17
|
-
-.38
|
|
18
|
-
],
|
|
19
|
-
Socket_Head: [
|
|
20
|
-
0,
|
|
21
|
-
0,
|
|
22
|
-
-.12
|
|
23
|
-
],
|
|
24
|
-
Socket_Back: [
|
|
25
|
-
0,
|
|
26
|
-
-.25,
|
|
27
|
-
.28
|
|
28
|
-
]
|
|
29
|
-
}), v = {
|
|
30
|
-
forward: !1,
|
|
31
|
-
backward: !1,
|
|
32
|
-
leftward: !1,
|
|
33
|
-
rightward: !1,
|
|
34
|
-
run: !1,
|
|
35
|
-
jump: !1
|
|
36
|
-
};
|
|
37
|
-
function y({ active: e, ecctrlRef: t }) {
|
|
38
|
-
let n = l({
|
|
39
|
-
w: !1,
|
|
40
|
-
s: !1,
|
|
41
|
-
a: !1,
|
|
42
|
-
d: !1,
|
|
43
|
-
shift: !1,
|
|
44
|
-
space: !1,
|
|
45
|
-
dirty: !1
|
|
46
|
-
}), r = l(e);
|
|
47
|
-
return o(() => {
|
|
48
|
-
if (!e || typeof window > "u" || typeof window.addEventListener != "function") return;
|
|
49
|
-
let t = (e) => (t) => {
|
|
50
|
-
let r = n.current;
|
|
51
|
-
t.code === "KeyW" || t.code === "ArrowUp" ? r.w !== e && (r.w = e, r.dirty = !0) : t.code === "KeyS" || t.code === "ArrowDown" ? r.s !== e && (r.s = e, r.dirty = !0) : t.code === "KeyA" || t.code === "ArrowLeft" ? r.a !== e && (r.a = e, r.dirty = !0) : t.code === "KeyD" || t.code === "ArrowRight" ? r.d !== e && (r.d = e, r.dirty = !0) : t.code === "ShiftLeft" || t.code === "ShiftRight" ? r.shift !== e && (r.shift = e, r.dirty = !0) : t.code === "Space" && r.space !== e && (r.space = e, r.dirty = !0);
|
|
52
|
-
}, r = () => {
|
|
53
|
-
let e = n.current;
|
|
54
|
-
(e.w || e.s || e.a || e.d || e.shift || e.space) && (e.w = !1, e.s = !1, e.a = !1, e.d = !1, e.shift = !1, e.space = !1, e.dirty = !0);
|
|
55
|
-
}, i = t(!0), a = t(!1);
|
|
56
|
-
return window.addEventListener("keydown", i), window.addEventListener("keyup", a), window.addEventListener("blur", r), () => {
|
|
57
|
-
window.removeEventListener("keydown", i), window.removeEventListener("keyup", a), window.removeEventListener("blur", r);
|
|
58
|
-
};
|
|
59
|
-
}, [e]), u(() => {
|
|
60
|
-
let i = t.current;
|
|
61
|
-
if (!i) return;
|
|
62
|
-
if (!e) {
|
|
63
|
-
if (r.current) {
|
|
64
|
-
let e = n.current;
|
|
65
|
-
e.w = !1, e.s = !1, e.a = !1, e.d = !1, e.shift = !1, e.space = !1, e.dirty = !1, v.forward = !1, v.backward = !1, v.leftward = !1, v.rightward = !1, v.run = !1, v.jump = !1, i.setMovement(v), r.current = !1;
|
|
66
|
-
}
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
r.current = !0;
|
|
70
|
-
let a = n.current;
|
|
71
|
-
a.dirty && (a.dirty = !1, v.forward = a.w, v.backward = a.s, v.leftward = a.a, v.rightward = a.d, v.run = a.shift, v.jump = a.space, i.setMovement(v));
|
|
72
|
-
}), null;
|
|
73
|
-
}
|
|
74
|
-
function b({ ref: o, si: u = t, smoothCamera: v = !1, makeDefaultCamera: b = !0, enableInput: S = !0, enable: C = !0, viewModelChildren: w, socketOffsets: T, children: E, userData: D, position: O, ...k }) {
|
|
75
|
-
let A = l(null), j = l(null), M = l(null), N = l({
|
|
76
|
-
Socket_Hand_R: null,
|
|
77
|
-
Socket_Hand_L: null,
|
|
78
|
-
Socket_Head: null,
|
|
79
|
-
Socket_Back: null
|
|
80
|
-
}), P = c(() => r(u), [u]), F = c(() => [
|
|
81
|
-
0,
|
|
82
|
-
i(u),
|
|
83
|
-
0
|
|
84
|
-
], [u]), I = d((e) => typeof e.gl?.domElement?.setAttribute == "function"), L = c(() => {
|
|
85
|
-
let e = D ?? {}, t = e.ecctrl ?? {};
|
|
86
|
-
return {
|
|
87
|
-
...e,
|
|
88
|
-
ecctrl: {
|
|
89
|
-
excludeVehicleRay: !0,
|
|
90
|
-
...t
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}, [D]);
|
|
94
|
-
return s(o, () => ({
|
|
95
|
-
get ecctrl() {
|
|
96
|
-
return A.current;
|
|
97
|
-
},
|
|
98
|
-
get cameraControls() {
|
|
99
|
-
return j.current;
|
|
100
|
-
},
|
|
101
|
-
socket(e) {
|
|
102
|
-
return N.current[e] ?? null;
|
|
103
|
-
},
|
|
104
|
-
syncCameraStep(e) {
|
|
105
|
-
a(j.current, e, P, v, A.current?.bodyYAxis);
|
|
106
|
-
}
|
|
107
|
-
}), [P, v]), /* @__PURE__ */ m(f, { children: [
|
|
108
|
-
/* @__PURE__ */ p(y, {
|
|
109
|
-
active: !!(C && S),
|
|
110
|
-
ecctrlRef: A
|
|
111
|
-
}),
|
|
112
|
-
/* @__PURE__ */ p(h, {
|
|
113
|
-
ref: A,
|
|
114
|
-
enable: C,
|
|
115
|
-
position: O ?? F,
|
|
116
|
-
capsuleHalfHeight: u.capsuleHalfHeight,
|
|
117
|
-
capsuleRadius: u.capsuleRadius,
|
|
118
|
-
floatHeight: u.floatHeight,
|
|
119
|
-
maxWalkVel: e.maxWalkVel,
|
|
120
|
-
maxRunVel: e.maxRunVel,
|
|
121
|
-
accDeltaTime: e.accDeltaTime,
|
|
122
|
-
decDeltaTime: e.decDeltaTime,
|
|
123
|
-
slideGripFactor: e.slideGripFactor,
|
|
124
|
-
moveImpulsePointOffset: e.moveImpulsePointOffset,
|
|
125
|
-
airDragFactor: e.airDragFactor,
|
|
126
|
-
enableToggleRun: e.enableToggleRun,
|
|
127
|
-
...k,
|
|
128
|
-
userData: L,
|
|
129
|
-
children: E
|
|
130
|
-
}),
|
|
131
|
-
I ? /* @__PURE__ */ p(g, {
|
|
132
|
-
ref: j,
|
|
133
|
-
makeDefault: b
|
|
134
|
-
}) : null,
|
|
135
|
-
/* @__PURE__ */ p(x, {
|
|
136
|
-
enable: C,
|
|
137
|
-
makeDefaultCamera: b,
|
|
138
|
-
ecctrlRef: A,
|
|
139
|
-
camControlsRef: j,
|
|
140
|
-
viewModelGroupRef: M,
|
|
141
|
-
eyeOffsetY: P,
|
|
142
|
-
smoothCamera: v
|
|
143
|
-
}),
|
|
144
|
-
/* @__PURE__ */ m("group", {
|
|
145
|
-
ref: M,
|
|
146
|
-
name: "KhrBody_ViewModel",
|
|
147
|
-
children: [n.map((e) => {
|
|
148
|
-
let t = T?.[e] ?? _[e];
|
|
149
|
-
return /* @__PURE__ */ p("group", {
|
|
150
|
-
name: e,
|
|
151
|
-
position: [
|
|
152
|
-
t[0],
|
|
153
|
-
t[1],
|
|
154
|
-
t[2]
|
|
155
|
-
],
|
|
156
|
-
ref: (t) => {
|
|
157
|
-
N.current[e] = t;
|
|
158
|
-
}
|
|
159
|
-
}, e);
|
|
160
|
-
}), w]
|
|
161
|
-
})
|
|
162
|
-
] });
|
|
163
|
-
}
|
|
164
|
-
function x({ enable: e, makeDefaultCamera: t, ecctrlRef: n, camControlsRef: r, viewModelGroupRef: i, eyeOffsetY: o, smoothCamera: s }) {
|
|
165
|
-
return u((c) => {
|
|
166
|
-
if (!e) return;
|
|
167
|
-
let l = n.current;
|
|
168
|
-
if (l) {
|
|
169
|
-
if (r.current) a(r.current, l.currPos, o, s, l.bodyYAxis);
|
|
170
|
-
else if (t) {
|
|
171
|
-
let e = l.bodyYAxis;
|
|
172
|
-
c.camera.position.set(l.currPos.x + e.x * o, l.currPos.y + e.y * o, l.currPos.z + e.z * o);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
let u = i.current;
|
|
176
|
-
u && (u.position.copy(c.camera.position), u.quaternion.copy(c.camera.quaternion));
|
|
177
|
-
}), null;
|
|
178
|
-
}
|
|
179
|
-
export { b as KhrBody, a as stepCameraSync };
|