Merge pull request #1 from Draythianna/main
Refine scale display and input precision in ScaleMenu 1.00-0.99-0.98...0.80 vs 1.0-0.9-0.8
This commit is contained in:
4 files changed
+52
-13
No files matched your search
+47
-8
@@ -24,6 +24,9 @@ local function norm(vec)
|
||||
return vec
|
||||
end
|
||||
|
||||
-- Per-ped smoothed Z, keyed by ped entity handle
|
||||
local smoothedZ = {}
|
||||
|
||||
local function applyScaleToEntity(ped, scale)
|
||||
local forward, right, upVector, position = GetEntityMatrix(ped)
|
||||
|
||||
@@ -31,20 +34,57 @@ local function applyScaleToEntity(ped, scale)
|
||||
local rightNorm = norm(right) * scale
|
||||
local upNorm = norm(upVector) * scale
|
||||
|
||||
local zOffset = (1.0 - scale) * 1.0 * 0.5
|
||||
local adjustedZ = position.z - zOffset
|
||||
-- Only look ahead when moving up, cast straight down when descending
|
||||
local vel = GetEntityVelocity(ped)
|
||||
local isMovingUp = vel.z > 0.1
|
||||
local lookAhead = isMovingUp and 0.3 or 0.0
|
||||
|
||||
if GetEntitySpeed(ped) > 0 then
|
||||
adjustedZ = adjustedZ - zOffset
|
||||
local rayStart = vector3(position.x + vel.x * lookAhead, position.y + vel.y * lookAhead, position.z + 2.0)
|
||||
local rayEnd = vector3(position.x + vel.x * lookAhead, position.y + vel.y * lookAhead, position.z - 2.5)
|
||||
local ray = StartShapeTestRay(rayStart.x, rayStart.y, rayStart.z, rayEnd.x, rayEnd.y, rayEnd.z, 1 | 16, ped, 0)
|
||||
local _, hit, groundPos = GetShapeTestResult(ray)
|
||||
|
||||
-- Fallback: straight down with longer range for flat ground / last step
|
||||
if hit ~= 1 then
|
||||
local rayStart2 = vector3(position.x, position.y, position.z + 2.0)
|
||||
local rayEnd2 = vector3(position.x, position.y, position.z - 5.0)
|
||||
local ray2 = StartShapeTestRay(rayStart2.x, rayStart2.y, rayStart2.z, rayEnd2.x, rayEnd2.y, rayEnd2.z, 1 | 16, ped, 0)
|
||||
_, hit, groundPos = GetShapeTestResult(ray2)
|
||||
end
|
||||
|
||||
local groundZ
|
||||
if hit == 1 then
|
||||
groundZ = groundPos.z
|
||||
else
|
||||
adjustedZ = adjustedZ + zOffset
|
||||
local found, gz = GetGroundZFor_3dCoord(position.x, position.y, position.z, false)
|
||||
groundZ = found and gz or position.z
|
||||
end
|
||||
|
||||
local targetZ = groundZ + scale + 0.04
|
||||
|
||||
local pedKey = tostring(ped)
|
||||
if smoothedZ[pedKey] == nil then
|
||||
smoothedZ[pedKey] = targetZ
|
||||
end
|
||||
|
||||
if targetZ > smoothedZ[pedKey] then
|
||||
-- Going up: snap for large steps, lerp for small ones
|
||||
local diff = targetZ - smoothedZ[pedKey]
|
||||
if diff > 0.3 then
|
||||
smoothedZ[pedKey] = targetZ
|
||||
else
|
||||
smoothedZ[pedKey] = smoothedZ[pedKey] + diff * 0.3
|
||||
end
|
||||
else
|
||||
-- Going down: always lerp smoothly
|
||||
smoothedZ[pedKey] = smoothedZ[pedKey] + (targetZ - smoothedZ[pedKey]) * 0.18
|
||||
end
|
||||
|
||||
SetEntityMatrix(ped,
|
||||
forwardNorm.x, forwardNorm.y, forwardNorm.z,
|
||||
rightNorm.x, rightNorm.y, rightNorm.z,
|
||||
upNorm.x, upNorm.y, upNorm.z,
|
||||
position.x, position.y, adjustedZ
|
||||
position.x, position.y, smoothedZ[pedKey]
|
||||
)
|
||||
end
|
||||
|
||||
@@ -128,7 +168,7 @@ RegisterNUICallback('get_config', function(data, cb)
|
||||
action = "config_data",
|
||||
data = {
|
||||
scaling = Config.scaling,
|
||||
currentScale = syncedScales[tostring(serverId)] or 1.0 -- Default to 1.0, you could store current scale in a variable
|
||||
currentScale = syncedScales[tostring(serverId)] or 1.0
|
||||
}
|
||||
})
|
||||
cb('ok')
|
||||
@@ -145,4 +185,3 @@ RegisterNetEvent('nass_pedscaler:openMenu', function()
|
||||
data = true,
|
||||
})
|
||||
end)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
version '1.0.0'
|
||||
version '1.0.1'
|
||||
|
||||
use_experimental_fxv2_oal 'yes'
|
||||
game 'gta5'
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! For license information please see app.js.LICENSE.txt */
|
||||
(()=>{"use strict";var e={780:(e,n,t)=>{t.d(n,{Z:()=>u});var r=t(81),l=t.n(r),a=t(645),o=t.n(a)()(l());o.push([e.id,"/* Reset and base styles */\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'SF Pro Display', system-ui, sans-serif;\n background: transparent;\n color: #ffffff;\n overflow: hidden;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n@keyframes modalFadeIn {\n to {\n transform: translateY(-50%) scale(1);\n opacity: 1;\n }\n}",""]);const u=o},645:e=>{e.exports=function(e){var n=[];return n.toString=function(){return this.map((function(n){var t="",r=void 0!==n[5];return n[4]&&(t+="@supports (".concat(n[4],") {")),n[2]&&(t+="@media ".concat(n[2]," {")),r&&(t+="@layer".concat(n[5].length>0?" ".concat(n[5]):""," {")),t+=e(n),r&&(t+="}"),n[2]&&(t+="}"),n[4]&&(t+="}"),t})).join("")},n.i=function(e,t,r,l,a){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(r)for(var u=0;u<this.length;u++){var i=this[u][0];null!=i&&(o[i]=!0)}for(var s=0;s<e.length;s++){var c=[].concat(e[s]);r&&o[c[0]]||(void 0!==a&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=a),t&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=t):c[2]=t),l&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=l):c[4]="".concat(l)),n.push(c))}},n}},81:e=>{e.exports=function(e){return e[1]}},448:(e,n,t)=>{var r=t(294),l=t(840);function a(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,t=1;t<arguments.length;t++)n+="&args[]="+encodeURIComponent(arguments[t]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,u={};function i(e,n){s(e,n),s(e+"Capture",n)}function s(e,n){for(u[e]=n,e=0;e<n.length;e++)o.add(n[e])}var c=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),f=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function h(e,n,t,r,l,a,o){this.acceptsBooleans=2===n||3===n||4===n,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=t,this.propertyName=e,this.type=n,this.sanitizeURL=a,this.removeEmptyString=o}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach((function(e){v[e]=new h(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((function(e){var n=e[0];v[n]=new h(n,1,!1,e[1],null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((function(e){v[e]=new h(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((function(e){v[e]=new h(e,2,!1,e,null,!1,!1)})),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach((function(e){v[e]=new h(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((function(e){v[e]=new h(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((function(e){v[e]=new h(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((function(e){v[e]=new h(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((function(e){v[e]=new h(e,5,!1,e.toLowerCase(),null,!1,!1)}));var g=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}function b(e,n,t,r){var l=v.hasOwnProperty(n)?v[n]:null;(null!==l?0!==l.type:r||!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&(function(e,n,t,r){if(null==n||function(e,n,t,r){if(null!==t&&0===t.type)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==t?!t.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,n,t,r))return!0;if(r)return!1;if(null!==t)switch(t.type){case 3:return!n;case 4:return!1===n;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}(n,t,l,r)&&(t=null),r||null===l?function(e){return!!f.call(m,e)||!f.call(p,e)&&(d.test(e)?m[e]=!0:(p[e]=!0,!1))}(n)&&(null===t?e.removeAttribute(n):e.setAttribute(n,""+t)):l.mustUseProperty?e[l.propertyName]=null===t?3!==l.type&&"":t:(n=l.attributeName,r=l.attributeNamespace,null===t?e.removeAttribute(n):(t=3===(l=l.type)||4===l&&!0===t?"":""+t,r?e.setAttriLine truncated
|
||||
(()=>{"use strict";var e={780:(e,n,t)=>{t.d(n,{Z:()=>u});var r=t(81),l=t.n(r),a=t(645),o=t.n(a)()(l());o.push([e.id,"/* Reset and base styles */\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'SF Pro Display', system-ui, sans-serif;\n background: transparent;\n color: #ffffff;\n overflow: hidden;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n@keyframes modalFadeIn {\n to {\n transform: translateY(-50%) scale(1);\n opacity: 1;\n }\n}",""]);const u=o},645:e=>{e.exports=function(e){var n=[];return n.toString=function(){return this.map((function(n){var t="",r=void 0!==n[5];return n[4]&&(t+="@supports (".concat(n[4],") {")),n[2]&&(t+="@media ".concat(n[2]," {")),r&&(t+="@layer".concat(n[5].length>0?" ".concat(n[5]):""," {")),t+=e(n),r&&(t+="}"),n[2]&&(t+="}"),n[4]&&(t+="}"),t})).join("")},n.i=function(e,t,r,l,a){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(r)for(var u=0;u<this.length;u++){var i=this[u][0];null!=i&&(o[i]=!0)}for(var s=0;s<e.length;s++){var c=[].concat(e[s]);r&&o[c[0]]||(void 0!==a&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=a),t&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=t):c[2]=t),l&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=l):c[4]="".concat(l)),n.push(c))}},n}},81:e=>{e.exports=function(e){return e[1]}},448:(e,n,t)=>{var r=t(294),l=t(840);function a(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,t=1;t<arguments.length;t++)n+="&args[]="+encodeURIComponent(arguments[t]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,u={};function i(e,n){s(e,n),s(e+"Capture",n)}function s(e,n){for(u[e]=n,e=0;e<n.length;e++)o.add(n[e])}var c=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),f=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function h(e,n,t,r,l,a,o){this.acceptsBooleans=2===n||3===n||4===n,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=t,this.propertyName=e,this.type=n,this.sanitizeURL=a,this.removeEmptyString=o}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach((function(e){v[e]=new h(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((function(e){var n=e[0];v[n]=new h(n,1,!1,e[1],null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((function(e){v[e]=new h(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((function(e){v[e]=new h(e,2,!1,e,null,!1,!1)})),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach((function(e){v[e]=new h(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((function(e){v[e]=new h(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((function(e){v[e]=new h(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((function(e){v[e]=new h(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((function(e){v[e]=new h(e,5,!1,e.toLowerCase(),null,!1,!1)}));var g=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}function b(e,n,t,r){var l=v.hasOwnProperty(n)?v[n]:null;(null!==l?0!==l.type:r||!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&(function(e,n,t,r){if(null==n||function(e,n,t,r){if(null!==t&&0===t.type)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==t?!t.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,n,t,r))return!0;if(r)return!1;if(null!==t)switch(t.type){case 3:return!n;case 4:return!1===n;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}(n,t,l,r)&&(t=null),r||null===l?function(e){return!!f.call(m,e)||!f.call(p,e)&&(d.test(e)?m[e]=!0:(p[e]=!0,!1))}(n)&&(null===t?e.removeAttribute(n):e.setAttribute(n,""+t)):l.mustUseProperty?e[l.propertyName]=null===t?3!==l.type&&"":t:(n=l.attributeName,r=l.attributeNamespace,null===t?e.removeAttribute(n):(t=3===(l=l.type)||4===l&&!0===t?"":""+t,r?e.setAttriLine truncated
|
||||
@@ -60,7 +60,7 @@ const ScaleMenu = ( { locale } ) => {
|
||||
<label className="flex justify-between items-center mb-4 text-sm text-white font-medium tracking-tight">
|
||||
<span>{locale["current_scale"]}</span>
|
||||
<span className="text-white font-bold text-sm py-1.5 px-3.5 rounded-lg border border-white/50 ">
|
||||
{currentScale}
|
||||
{parseFloat(currentScale).toFixed(2)}
|
||||
</span>
|
||||
</label>
|
||||
|
||||
@@ -69,8 +69,8 @@ const ScaleMenu = ( { locale } ) => {
|
||||
type="range"
|
||||
min={minScale}
|
||||
max={maxScale}
|
||||
step="0.1"
|
||||
value={currentScale}
|
||||
step="0.01"
|
||||
value={parseFloat(currentScale).toFixed(2)}
|
||||
onChange={handleScaleChange}
|
||||
className="
|
||||
w-full h-1
|
||||
|
||||
Reference in new issue
Block a user