23w49a "Service Pack #1" Various Fixes
This commit is contained in:
parent
f573dbb78b
commit
b31e337a55
|
@ -37,7 +37,7 @@ dependencies {
|
|||
teavm {
|
||||
|
||||
compileScopes = null;
|
||||
minifying = false;
|
||||
minifying = true;
|
||||
maxTopLevelNames = 10000;
|
||||
properties = null;
|
||||
debugInformationGenerated = false;
|
||||
|
|
Binary file not shown.
163259
javascript/classes.js
163259
javascript/classes.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,7 @@
|
|||
|
||||
// eaglercraft opengl 1.3 emulation
|
||||
// copyright (c) 2020 calder young
|
||||
// creative commons BY-NC 4.0
|
||||
// copyright (c) 2020-2023 lax1dude
|
||||
|
||||
#line 7
|
||||
#line 4
|
||||
|
||||
precision highp int;
|
||||
precision highp sampler2D;
|
||||
|
@ -99,6 +97,8 @@ in vec2 v_texture0;
|
|||
|
||||
out vec4 fragColor;
|
||||
|
||||
#define TEX_MAT3x2(mat4In) mat3x2(mat4In[0].xy,mat4In[1].xy,mat4In[3].xy)
|
||||
|
||||
void main(){
|
||||
#ifdef CC_a_color
|
||||
vec4 color = colorUniform * v_color;
|
||||
|
@ -108,9 +108,9 @@ void main(){
|
|||
|
||||
#ifdef CC_unit0
|
||||
#ifdef CC_a_texture0
|
||||
color *= texture(tex0, (matrix_t * vec4(v_texture0, 0.0, 1.0)).xy).rgba;
|
||||
color *= texture(tex0, (TEX_MAT3x2(matrix_t) * vec3(v_texture0, 1.0)).xy).rgba;
|
||||
#else
|
||||
color *= texture(tex0, (matrix_t * vec4(texCoordV0, 0.0, 1.0)).xy).rgba;
|
||||
color *= texture(tex0, (TEX_MAT3x2(matrix_t) * vec3(texCoordV0, 1.0)).xy).rgba;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -133,7 +133,7 @@ void main(){
|
|||
|
||||
#ifdef CC_fog
|
||||
float dist = sqrt(dot(v_position, v_position));
|
||||
float i = (fogMode == 1) ? clamp((dist - fogStart) / (fogEnd - fogStart), 0.0, 1.0) : clamp(1.0 - pow(2.718, -(fogDensity * dist)), 0.0, 1.0);
|
||||
float i = (fogMode == 1) ? clamp((dist - fogStart) / (fogEnd - fogStart), 0.0, 1.0) : clamp(1.0 - exp(-(fogDensity * dist)), 0.0, 1.0);
|
||||
color.rgb = mix(color.rgb, fogColor.xyz, i * fogColor.a);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,18 +1,68 @@
|
|||
#line 0
|
||||
#line 2
|
||||
|
||||
// Remove this line below if you plan to modify this file
|
||||
#define USE_OPTIMIZED
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved.
|
||||
*
|
||||
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
|
||||
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
|
||||
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
|
||||
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
|
||||
*
|
||||
* NOT FOR COMMERCIAL OR MALICIOUS USE
|
||||
*
|
||||
* (please read the 'LICENSE' file this repo's root directory for more info)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This file was modified by lax1dude to remove dead code
|
||||
*
|
||||
* Original: https://gist.github.com/kosua20/0c506b81b3812ac900048059d2383126
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* ============================================================================
|
||||
*
|
||||
*
|
||||
* NVIDIA FXAA 3.11 by TIMOTHY LOTTES
|
||||
*
|
||||
*
|
||||
* ------------------------------------------------------------------------------
|
||||
* COPYRIGHT (C) 2010, 2011 NVIDIA CORPORATION. ALL RIGHTS RESERVED.
|
||||
* ------------------------------------------------------------------------------
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
|
||||
* *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
|
||||
* OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
|
||||
* OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
|
||||
* CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR
|
||||
* LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,
|
||||
* OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE
|
||||
* THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGES.
|
||||
*
|
||||
*/
|
||||
|
||||
precision lowp int;
|
||||
precision lowp sampler2D;
|
||||
precision lowp float;
|
||||
precision mediump float;
|
||||
precision mediump sampler2D;
|
||||
|
||||
|
||||
in vec2 pos;
|
||||
|
||||
out vec4 fragColor;
|
||||
layout(location = 0) out vec4 output4f;
|
||||
|
||||
#define FXAA_PC 1
|
||||
#define FXAA_GLSL_130 1
|
||||
#define FXAA_FAST_PIXEL_OFFSET 0
|
||||
#define FXAA_GATHER4_ALPHA 0
|
||||
uniform sampler2D f_color;
|
||||
uniform vec2 screenSize;
|
||||
|
||||
#ifndef USE_OPTIMIZED
|
||||
#ifndef FXAA_GREEN_AS_LUMA
|
||||
// For those using non-linear color,
|
||||
// and either not able to get luma in alpha, or not wanting to,
|
||||
|
@ -31,7 +81,7 @@ out vec4 fragColor;
|
|||
// 1 = On.
|
||||
// 0 = Off.
|
||||
//
|
||||
#define FXAA_GREEN_AS_LUMA 1
|
||||
#define FXAA_GREEN_AS_LUMA 0
|
||||
#endif
|
||||
|
||||
#ifndef FXAA_DISCARD
|
||||
|
@ -58,14 +108,13 @@ out vec4 fragColor;
|
|||
#define FxaaTex sampler2D
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
#define FxaaTexTop(t, p) texture(t, p)
|
||||
#define FxaaTexTop(t, p) textureLod(t, p, 0.0)
|
||||
|
||||
/*============================================================================
|
||||
GREEN AS LUMA OPTION SUPPORT FUNCTION
|
||||
============================================================================*/
|
||||
#if (FXAA_GREEN_AS_LUMA == 0)
|
||||
// TODO Luma
|
||||
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return dot(rgba.xyz, vec3(0.299, 0.587, 0.114)); }
|
||||
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return dot(rgba.xyz * rgba.xyz, vec3(0.299, 0.587, 0.114)); }
|
||||
#else
|
||||
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }
|
||||
#endif
|
||||
|
@ -232,24 +281,91 @@ FxaaFloat4 FxaaPixelShader(
|
|||
}
|
||||
/*==========================================================================*/
|
||||
|
||||
uniform sampler2D f_color;
|
||||
|
||||
uniform vec2 screenSize;
|
||||
|
||||
#define edgeSharpness 7.0
|
||||
#define edgeThreshold 0.1
|
||||
#define edgeThresholdMin 0.005
|
||||
#define edgeSharpness 3.0
|
||||
#define edgeThreshold 0.15
|
||||
#define edgeThresholdMin 0.05
|
||||
|
||||
void main(){
|
||||
vec2 screenSize05 = 0.5 * screenSize;
|
||||
|
||||
vec4 posPos;
|
||||
posPos.xy = pos - (0.6 / screenSize);
|
||||
posPos.zw = pos + (0.6 / screenSize);
|
||||
vec4 rcpFrameOpt;
|
||||
rcpFrameOpt.xy = vec2(-0.50, -0.50) / screenSize;
|
||||
rcpFrameOpt.zw = vec2( 0.50, 0.50) / screenSize;
|
||||
vec4 rcpFrameOpt2;
|
||||
rcpFrameOpt2.xy = vec2(-2.0, -2.0) / screenSize;
|
||||
rcpFrameOpt2.zw = vec2( 2.0, 2.0) / screenSize;
|
||||
|
||||
fragColor = vec4(FxaaPixelShader(pos, posPos, f_color, rcpFrameOpt, rcpFrameOpt2, edgeSharpness, edgeThreshold, edgeThresholdMin).rgb, 1.0);
|
||||
posPos.xy = pos;
|
||||
posPos.zw = pos + screenSize;
|
||||
|
||||
vec4 rcpFrameOpt;
|
||||
rcpFrameOpt.xy = -screenSize05;
|
||||
rcpFrameOpt.zw = screenSize05;
|
||||
|
||||
output4f = vec4(FxaaPixelShader(pos + screenSize05, posPos, f_color, rcpFrameOpt, rcpFrameOpt * 4.0, edgeSharpness, edgeThreshold, edgeThresholdMin).rgb, 1.0);
|
||||
}
|
||||
#else
|
||||
|
||||
// This 'optimized' code was generated using glslangValidator + spirv-cross + spirv-opt on the source code above
|
||||
// Is it faster? Idfk, probably compiles faster at least, what matters it I tried
|
||||
|
||||
float _616;
|
||||
vec4 _617;
|
||||
|
||||
void main()
|
||||
{
|
||||
mediump vec2 _257 = screenSize * 0.5;
|
||||
mediump vec4 _611 = vec4(pos, pos + screenSize);
|
||||
mediump vec4 _612 = vec4(_616, _616, _257);
|
||||
mediump vec2 _290 = pos + _257;
|
||||
mediump vec4 _608;
|
||||
for(;;)
|
||||
{
|
||||
mediump vec3 _532 = textureLod(f_color, _611.xy, 0.0).xyz;
|
||||
mediump float _536 = dot(_532 * _532, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
|
||||
mediump vec3 _540 = textureLod(f_color, _611.xw, 0.0).xyz;
|
||||
mediump float _544 = dot(_540 * _540, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
|
||||
mediump vec3 _548 = textureLod(f_color, _611.zy, 0.0).xyz;
|
||||
mediump vec3 _556 = textureLod(f_color, _611.zw, 0.0).xyz;
|
||||
mediump float _560 = dot(_556 * _556, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
|
||||
mediump vec4 _390 = textureLod(f_color, _290, 0.0);
|
||||
mediump vec3 _564 = _390.xyz;
|
||||
mediump float _568 = dot(_564 * _564, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
|
||||
mediump float _397 = dot(_548 * _548, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)) + 0.00260416674427688121795654296875;
|
||||
mediump float _409 = max(max(_397, _560), max(_536, _544));
|
||||
mediump float _412 = min(min(_397, _560), min(_536, _544));
|
||||
mediump float _427 = _544 - _397;
|
||||
mediump float _433 = _560 - _536;
|
||||
if ((max(_409, _568) - min(_412, _568)) < max(0.0500000007450580596923828125, _409 * 0.1500000059604644775390625))
|
||||
{
|
||||
_608 = _390;
|
||||
break;
|
||||
}
|
||||
mediump vec2 _449 = normalize(vec2(_427 + _433, _427 - _433));
|
||||
vec2 hp_copy_449 = _449;
|
||||
mediump vec2 _454 = _612.zw;
|
||||
vec2 _614 = -hp_copy_449;
|
||||
mediump vec2 mp_copy_614 = _614;
|
||||
mediump vec2 _481 = clamp(_449 / vec2(min(abs(_449.x), abs(_449.y)) * 3.0), vec2(-2.0), vec2(2.0));
|
||||
vec2 hp_copy_481 = _481;
|
||||
mediump vec2 _484 = (_612 * 4.0).zw;
|
||||
vec2 _615 = -hp_copy_481;
|
||||
mediump vec2 mp_copy_615 = _615;
|
||||
mediump vec4 _498 = textureLod(f_color, mp_copy_614 * _454 + _290, 0.0) + textureLod(f_color, _449 * _454 + _290, 0.0);
|
||||
mediump vec4 _505 = ((textureLod(f_color, mp_copy_615 * _484 + _290, 0.0) + textureLod(f_color, _481 * _484 + _290, 0.0)) * 0.25) + (_498 * 0.25);
|
||||
mediump float _576 = dot(_505.xyz * _505.xyz, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
|
||||
mediump vec4 _607;
|
||||
if ((_576 < _412) || (_576 > _409))
|
||||
{
|
||||
mediump vec3 _518 = _498.xyz * 0.5;
|
||||
mediump vec4 _600;
|
||||
_600.x = _518.x;
|
||||
_600.y = _518.y;
|
||||
_600.z = _518.z;
|
||||
_607 = _600;
|
||||
}
|
||||
else
|
||||
{
|
||||
_607 = _505;
|
||||
}
|
||||
_608 = _607;
|
||||
break;
|
||||
}
|
||||
output4f = vec4(_608.xyz, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -4,10 +4,10 @@ public class ConfigConstants {
|
|||
|
||||
public static boolean profanity = false;
|
||||
|
||||
public static final String version = "22w22b";
|
||||
public static final String version = "23w49a";
|
||||
public static final String mainMenuString = "eaglercraft beta-" + version;
|
||||
|
||||
public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft";
|
||||
public static final String forkMe = null;
|
||||
|
||||
public static final boolean html5build = true;
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -91,7 +91,7 @@ public class EffectPipelineFXAA {
|
|||
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST);
|
||||
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP);
|
||||
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP);
|
||||
_wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGB8, width, height, 0, _wGL_RGB, _wGL_UNSIGNED_BYTE, (ByteBuffer)null);
|
||||
_wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGBA8, width, height, 0, _wGL_RGBA, _wGL_UNSIGNED_BYTE, (ByteBuffer)null);
|
||||
|
||||
framebuffer_depth = _wglCreateRenderBuffer();
|
||||
_wglBindRenderbuffer(framebuffer_depth);
|
||||
|
@ -125,7 +125,7 @@ public class EffectPipelineFXAA {
|
|||
initFXAA();
|
||||
}else {
|
||||
_wglBindTexture(_wGL_TEXTURE_2D, fxaaSourceTexture);
|
||||
_wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGB8, width, height, 0, _wGL_RGB, _wGL_UNSIGNED_BYTE, (ByteBuffer)null);
|
||||
_wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGBA8, width, height, 0, _wGL_RGBA, _wGL_UNSIGNED_BYTE, (ByteBuffer)null);
|
||||
_wglBindRenderbuffer(framebuffer_depth);
|
||||
_wglRenderbufferStorage(_wGL_DEPTH_COMPONENT32F, width, height);
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ public class EffectPipelineFXAA {
|
|||
_wglDisable(_wGL_CULL_FACE);
|
||||
_wglDepthMask(false);
|
||||
_wglUseProgram(fxaaProgram);
|
||||
_wglUniform2f(fxaaScreenSize, width, height);
|
||||
_wglUniform2f(fxaaScreenSize, 1.0f / width, 1.0f / height);
|
||||
_wglBindVertexArray(renderQuadArray);
|
||||
_wglDrawArrays(_wGL_TRIANGLES, 0, 6);
|
||||
_wglEnable(_wGL_DEPTH_TEST);
|
||||
|
|
|
@ -571,7 +571,7 @@ public class RenderGlobal implements IWorldAccess {
|
|||
float f12 = ((float) j * 3.141593F * 2.0F) / (float) i;
|
||||
float f14 = MathHelper.sin(f12);
|
||||
float f15 = MathHelper.cos(f12);
|
||||
tessellator.addVertex(f14 * 120F, f15 * 120F, -f15 * 40F * af[3]);
|
||||
tessellator.addVertex(f14 * 120F, f15 * 120F, f15 * 40F * af[3]);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
|
|
|
@ -77,7 +77,7 @@ public class SoundManager {
|
|||
try {
|
||||
EaglerAdapter.setListenerPos((float)x, (float)y, (float)z, (float)par1EntityLiving.motionX, (float)par1EntityLiving.motionY, (float)par1EntityLiving.motionZ, (float)pitch, (float)yaw);
|
||||
}catch(Throwable t) {
|
||||
System.err.println("AudioListener f***ed up again");
|
||||
System.err.println("AudioListener is being a vigg again");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -26,6 +26,7 @@ import org.teavm.jso.browser.TimerHandler;
|
|||
import org.teavm.jso.browser.Window;
|
||||
import org.teavm.jso.canvas.CanvasRenderingContext2D;
|
||||
import org.teavm.jso.canvas.ImageData;
|
||||
import org.teavm.jso.dom.css.CSSStyleDeclaration;
|
||||
import org.teavm.jso.dom.events.Event;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.dom.events.KeyboardEvent;
|
||||
|
@ -207,13 +208,18 @@ public class EaglerAdapterImpl2 {
|
|||
win = Window.current();
|
||||
doc = win.getDocument();
|
||||
canvas = (HTMLCanvasElement)doc.createElement("canvas");
|
||||
width = rootElement.getClientWidth();
|
||||
height = rootElement.getClientHeight();
|
||||
double r = win.getDevicePixelRatio();
|
||||
width = (int)(rootElement.getClientWidth() * r);
|
||||
height = (int)(rootElement.getClientHeight() * r);
|
||||
canvas.setWidth(width);
|
||||
canvas.setHeight(height);
|
||||
canvasContext = (CanvasRenderingContext2D) canvas.getContext("2d");
|
||||
canvas.setAttribute("id", "deevis589723589");
|
||||
rootElement.appendChild(canvas);
|
||||
CSSStyleDeclaration canvasStyle = canvas.getStyle();
|
||||
canvasStyle.setProperty("width", "100%");
|
||||
canvasStyle.setProperty("height", "100%");
|
||||
canvasStyle.setProperty("image-rendering", "pixelated");
|
||||
canvasBack = (HTMLCanvasElement)doc.createElement("canvas");
|
||||
canvasBack.setWidth(width);
|
||||
canvasBack.setHeight(height);
|
||||
|
@ -259,8 +265,9 @@ public class EaglerAdapterImpl2 {
|
|||
canvas.addEventListener("mousemove", mousemove = new EventListener<MouseEvent>() {
|
||||
@Override
|
||||
public void handleEvent(MouseEvent evt) {
|
||||
mouseX = getOffsetX(evt);
|
||||
mouseY = canvas.getClientHeight() - getOffsetY(evt);
|
||||
double r = win.getDevicePixelRatio();
|
||||
mouseX = (int)(getOffsetX(evt) * r);
|
||||
mouseY = (int)((canvas.getClientHeight() - getOffsetY(evt)) * r);
|
||||
mouseDX += evt.getMovementX();
|
||||
mouseDY += -evt.getMovementY();
|
||||
evt.preventDefault();
|
||||
|
@ -1056,10 +1063,10 @@ public class EaglerAdapterImpl2 {
|
|||
return mouseY;
|
||||
}
|
||||
public static final int mouseGetEventX() {
|
||||
return currentEvent == null ? -1 : currentEvent.getClientX();
|
||||
return currentEvent == null ? -1 : (int)(currentEvent.getClientX() * win.getDevicePixelRatio());
|
||||
}
|
||||
public static final int mouseGetEventY() {
|
||||
return currentEvent == null ? -1 : canvas.getClientHeight() - currentEvent.getClientY();
|
||||
return currentEvent == null ? -1 : (int)((canvas.getClientHeight() - currentEvent.getClientY()) * win.getDevicePixelRatio());
|
||||
}
|
||||
public static final boolean keysNext() {
|
||||
if(unpressCTRL) { //un-press ctrl after copy/paste permission
|
||||
|
@ -1121,10 +1128,10 @@ public class EaglerAdapterImpl2 {
|
|||
|
||||
public static final void updateDisplay() {
|
||||
commitContext(webgl);
|
||||
canvasContext.drawImage(canvasBack, 0d, 0d, canvas.getWidth(), canvas.getHeight());
|
||||
|
||||
int ww = canvas.getClientWidth();
|
||||
int hh = canvas.getClientHeight();
|
||||
canvasContext.drawImage(canvasBack, 0d, 0d, canvasBack.getWidth(), canvasBack.getHeight());
|
||||
double r = win.getDevicePixelRatio();
|
||||
int ww = (int)(canvas.getClientWidth() * r);
|
||||
int hh = (int)(canvas.getClientHeight() * r);
|
||||
if(ww != width || hh != height) {
|
||||
width = ww;
|
||||
height = hh;
|
||||
|
@ -1171,7 +1178,7 @@ public class EaglerAdapterImpl2 {
|
|||
return win.getScreen().getAvailHeight();
|
||||
}
|
||||
public static final int getCanvasWidth() {
|
||||
int w = parent.getClientWidth();
|
||||
int w = (int)(parent.getClientWidth() * win.getDevicePixelRatio());
|
||||
if(w != width) {
|
||||
canvas.setWidth(w);
|
||||
canvasBack.setWidth(w);
|
||||
|
@ -1180,7 +1187,7 @@ public class EaglerAdapterImpl2 {
|
|||
return w;
|
||||
}
|
||||
public static final int getCanvasHeight() {
|
||||
int h = parent.getClientHeight();
|
||||
int h = (int)(parent.getClientHeight() * win.getDevicePixelRatio());
|
||||
if(h != height) {
|
||||
canvas.setHeight(h);
|
||||
canvasBack.setHeight(h);
|
||||
|
@ -1474,26 +1481,34 @@ public class EaglerAdapterImpl2 {
|
|||
public static final int beginPlayback(String fileName, float x, float y, float z, float volume, float pitch) {
|
||||
AudioBuffer b = getBufferFor(fileName);
|
||||
if(b == null) return -1;
|
||||
AudioBufferSourceNode s = audioctx.createBufferSource();
|
||||
s.setBuffer(b);
|
||||
s.getPlaybackRate().setValue(pitch);
|
||||
PannerNode p = audioctx.createPanner();
|
||||
p.setPosition(x, y, z);
|
||||
p.setMaxDistance(volume * 16f + 0.1f);
|
||||
p.setRolloffFactor(1f);
|
||||
//p.setVelocity(0f, 0f, 0f);
|
||||
p.setDistanceModel("linear");
|
||||
p.setPanningModel("HRTF");
|
||||
p.setConeInnerAngle(360f);
|
||||
p.setConeOuterAngle(0f);
|
||||
p.setConeOuterGain(0f);
|
||||
p.setOrientation(0f, 1f, 0f);
|
||||
GainNode g = audioctx.createGain();
|
||||
g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
|
||||
s.connect(g);
|
||||
g.connect(p);
|
||||
p.connect(audioctx.getDestination());
|
||||
s.start(0.0d, playbackOffsetDelay);
|
||||
AudioBufferSourceNode s;
|
||||
PannerNode p;
|
||||
GainNode g;
|
||||
try {
|
||||
s = audioctx.createBufferSource();
|
||||
s.setBuffer(b);
|
||||
s.getPlaybackRate().setValue(pitch);
|
||||
p = audioctx.createPanner();
|
||||
p.setPosition(x, y, z);
|
||||
p.setMaxDistance(volume * 16f + 0.1f);
|
||||
p.setRolloffFactor(1f);
|
||||
//p.setVelocity(0f, 0f, 0f);
|
||||
p.setDistanceModel("linear");
|
||||
p.setPanningModel("HRTF");
|
||||
p.setConeInnerAngle(360f);
|
||||
p.setConeOuterAngle(0f);
|
||||
p.setConeOuterGain(0f);
|
||||
p.setOrientation(0f, 1f, 0f);
|
||||
g = audioctx.createGain();
|
||||
g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
|
||||
s.connect(g);
|
||||
g.connect(p);
|
||||
p.connect(audioctx.getDestination());
|
||||
s.start(0.0d, playbackOffsetDelay);
|
||||
}catch(Throwable t) {
|
||||
System.err.println("Failed to set up 3D audio source node! " + t.toString());
|
||||
return -1;
|
||||
}
|
||||
final int theId = ++playbackId;
|
||||
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g));
|
||||
s.setOnEnded(new EventListener<MediaEvent>() {
|
||||
|
@ -1509,14 +1524,21 @@ public class EaglerAdapterImpl2 {
|
|||
public static final int beginPlaybackStatic(String fileName, float volume, float pitch) {
|
||||
AudioBuffer b = getBufferFor(fileName);
|
||||
if(b == null) return -1;
|
||||
AudioBufferSourceNode s = audioctx.createBufferSource();
|
||||
s.setBuffer(b);
|
||||
s.getPlaybackRate().setValue(pitch);
|
||||
GainNode g = audioctx.createGain();
|
||||
g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
|
||||
s.connect(g);
|
||||
g.connect(audioctx.getDestination());
|
||||
s.start(0.0d, playbackOffsetDelay);
|
||||
AudioBufferSourceNode s;
|
||||
GainNode g;
|
||||
try {
|
||||
s = audioctx.createBufferSource();
|
||||
s.setBuffer(b);
|
||||
s.getPlaybackRate().setValue(pitch);
|
||||
g = audioctx.createGain();
|
||||
g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
|
||||
s.connect(g);
|
||||
g.connect(audioctx.getDestination());
|
||||
s.start(0.0d, playbackOffsetDelay);
|
||||
}catch(Throwable t) {
|
||||
System.err.println("Failed to set up 2D audio source node! " + t.toString());
|
||||
return -1;
|
||||
}
|
||||
final int theId = ++playbackId;
|
||||
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g));
|
||||
s.setOnEnded(new EventListener<MediaEvent>() {
|
||||
|
@ -1544,7 +1566,11 @@ public class EaglerAdapterImpl2 {
|
|||
public static final void moveSound(int id, float x, float y, float z, float vx, float vy, float vz) {
|
||||
AudioBufferSourceNodeX b = activeSoundEffects.get(id);
|
||||
if(b != null && b.panner != null) {
|
||||
b.panner.setPosition(x, y, z);
|
||||
try {
|
||||
b.panner.setPosition(x, y, z);
|
||||
}catch(Throwable t) {
|
||||
System.err.println("Could not reposition audio node " + id + ": " + t.toString());
|
||||
}
|
||||
//b.panner.setVelocity(vx, vy, vz);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user