@adatechnology/game-vfx-three 0.10.8 → 0.10.10
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/dist/{chunk-GHLGSWLP.js → chunk-EE6XER4D.js} +25 -18
- package/dist/chunk-EE6XER4D.js.map +1 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.global.js +28 -19
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-GHLGSWLP.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -137,7 +137,8 @@ var GameVfxThree = (() => {
|
|
|
137
137
|
PIECE_BOXES: "destruction.piece-boxes",
|
|
138
138
|
STATIC_COLLIDERS: "destruction.static-colliders",
|
|
139
139
|
SHAPES_GENERATE: "shapes.generate",
|
|
140
|
-
WORLD_REGION: "world.region"
|
|
140
|
+
WORLD_REGION: "world.region",
|
|
141
|
+
VEHICLE_HULL_PLAN: "vehicles.hull-plan"
|
|
141
142
|
};
|
|
142
143
|
var WORKER_KIND_DEFAULTS = {
|
|
143
144
|
[WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
|
|
@@ -145,7 +146,8 @@ var GameVfxThree = (() => {
|
|
|
145
146
|
[WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
|
|
146
147
|
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
147
148
|
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
148
|
-
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" }
|
|
149
|
+
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" },
|
|
150
|
+
[WORKER_KIND_ID.VEHICLE_HULL_PLAN]: { lane: "build", priority: 120, late: "keep-waiting" }
|
|
149
151
|
};
|
|
150
152
|
|
|
151
153
|
// ../game-vfx/dist/index.js
|
|
@@ -8763,21 +8765,22 @@ float vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);
|
|
|
8763
8765
|
// src/shaders/puff.ts
|
|
8764
8766
|
var PUFF_VERTEX = `${GL_NOISE}
|
|
8765
8767
|
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
|
|
8766
|
-
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
8768
|
+
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
8767
8769
|
void main(){
|
|
8768
8770
|
vec3 p=position;
|
|
8771
|
+
vec3 q=normalize(position);
|
|
8769
8772
|
float s=aD.z;
|
|
8770
8773
|
float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
|
|
8771
8774
|
p*=0.78+0.5*n;
|
|
8772
|
-
float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;
|
|
8773
|
-
vL=p;
|
|
8775
|
+
float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;q.xz=mat2(c,-si,si,c)*q.xz;
|
|
8776
|
+
vL=p;vN=q;
|
|
8774
8777
|
vec3 wp=aP.xyz+p*aP.w;
|
|
8775
8778
|
vWP=wp;vD=aD;vC=aC;
|
|
8776
8779
|
gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
|
|
8777
8780
|
}`;
|
|
8778
8781
|
var PUFF_FRAGMENT = `${GL_NOISE}
|
|
8779
8782
|
uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
|
|
8780
|
-
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
8783
|
+
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
8781
8784
|
vec3 L(vec3 c){return pow(c,vec3(2.2));}
|
|
8782
8785
|
vec3 ramp(float h){
|
|
8783
8786
|
vec3 c0=L(vec3(.36,.07,.03)),c1=L(vec3(.76,.21,.1)),c2=L(vec3(1.,.54,.16)),c3=L(vec3(1.,.83,.42)),c4=L(vec3(1.,.96,.84));
|
|
@@ -8787,30 +8790,35 @@ vec3 ramp(float h){
|
|
|
8787
8790
|
return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
|
|
8788
8791
|
}
|
|
8789
8792
|
void main(){
|
|
8790
|
-
vec3 N=normalize(cross(dFdx(vWP),dFdy(vWP)));
|
|
8791
8793
|
float age=vD.x,heat=vD.y,kind=vD.w;
|
|
8792
8794
|
float n=vn(vL*2.4+vD.z*13.0);
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
+
// the sphere's own normal, roughened by the noise: a billowing cloud, never facets
|
|
8796
|
+
vec3 g=vec3(vn(vL*3.1+vD.z*5.0),vn(vL*3.1+vD.z*5.0+7.3),vn(vL*3.1+vD.z*5.0+13.7))-.5;
|
|
8797
|
+
vec3 N=normalize(normalize(vN)+g*.9);
|
|
8798
|
+
vec3 V=normalize(cameraPosition-vWP);
|
|
8795
8799
|
float lam=max(dot(N,uLight),0.);
|
|
8796
|
-
float
|
|
8797
|
-
// soot: a dark smoke still scatters some light, so it never goes flat black, and its rim takes the sky so its volume reads (only the dark puffs; the rest as the Lab)
|
|
8800
|
+
float light=.42+.62*smoothstep(-.1,.9,lam);
|
|
8798
8801
|
float dark=1.-smoothstep(.02,.12,dot(vC,vec3(.2126,.7152,.0722)));
|
|
8799
8802
|
vec3 alb=max(vC,vec3(.055)*dark);
|
|
8800
|
-
vec3 col=alb*(vec3(.5,.56,.7)*
|
|
8801
|
-
float rim=pow(1.-clamp(abs(dot(
|
|
8803
|
+
vec3 col=alb*(vec3(.5,.56,.7)*light*1.05+vec3(.2,.19,.18)+uGround*(.4-.4*N.y));
|
|
8804
|
+
float rim=pow(1.-clamp(abs(dot(normalize(vN),V)),0.,1.),2.);
|
|
8802
8805
|
col+=dark*rim*(uSky*.9+alb);
|
|
8803
8806
|
vec3 tg=uGlowPos-vWP;float dg=length(tg)+.001;
|
|
8804
8807
|
float gi=uGlowI/(1.+dg*dg*.05)*(.3+.7*max(dot(N,tg/dg),0.));
|
|
8805
8808
|
col+=uGlowCol*gi*alb*1.6;
|
|
8809
|
+
// seen through: thin where the camera grazes the puff, thicker where the noise is, thinning out with age
|
|
8810
|
+
float facing=abs(dot(normalize(vN),V));
|
|
8811
|
+
float alpha=smoothstep(.0,.75,facing)*(.35+.65*smoothstep(.2,.8,n))*(1.-smoothstep(.3,1.,age))*.78;
|
|
8806
8812
|
float h=heat*(.72+.56*n)+heat*(-N.y)*.18;
|
|
8807
8813
|
if(h>.05){
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
col=mix(col,fc,
|
|
8814
|
+
vec3 fc=ramp(clamp(h,0.,1.2))*(1.1+3.1*h);
|
|
8815
|
+
float hot=smoothstep(.04,.2,h);
|
|
8816
|
+
col=mix(col,fc,hot);
|
|
8817
|
+
alpha=max(alpha,hot*smoothstep(.0,.45,facing)*(1.-smoothstep(.5,1.,age)));
|
|
8811
8818
|
}
|
|
8812
8819
|
if(kind>2.5&&kind<3.5){col+=vec3(.02,.025,.03);}
|
|
8813
|
-
|
|
8820
|
+
if(alpha<.01)discard;
|
|
8821
|
+
gl_FragColor=vec4(col,alpha);
|
|
8814
8822
|
#include <tonemapping_fragment>
|
|
8815
8823
|
#include <colorspace_fragment>
|
|
8816
8824
|
}`;
|
|
@@ -8849,10 +8857,11 @@ void main(){
|
|
|
8849
8857
|
function dynamic(THREE, array, size) {
|
|
8850
8858
|
return new THREE.InstancedBufferAttribute(array, size).setUsage(THREE.DynamicDrawUsage);
|
|
8851
8859
|
}
|
|
8860
|
+
var PUFF_DETAIL = 2;
|
|
8852
8861
|
function createPuffLayer(THREE, pool, uniforms) {
|
|
8853
8862
|
const capacity = pool.capacity;
|
|
8854
8863
|
const geometry = new THREE.InstancedBufferGeometry();
|
|
8855
|
-
geometry.setAttribute("position", new THREE.IcosahedronGeometry(1,
|
|
8864
|
+
geometry.setAttribute("position", new THREE.IcosahedronGeometry(1, PUFF_DETAIL).getAttribute("position"));
|
|
8856
8865
|
const a = new Float32Array(capacity * 4);
|
|
8857
8866
|
const d = new Float32Array(capacity * 4);
|
|
8858
8867
|
const c = new Float32Array(capacity * 3);
|
|
@@ -8861,7 +8870,7 @@ void main(){
|
|
|
8861
8870
|
geometry.setAttribute("aD", attributes[1]);
|
|
8862
8871
|
geometry.setAttribute("aC", attributes[2]);
|
|
8863
8872
|
geometry.instanceCount = 0;
|
|
8864
|
-
const material2 = new THREE.ShaderMaterial({ uniforms, vertexShader: PUFF_VERTEX, fragmentShader: PUFF_FRAGMENT });
|
|
8873
|
+
const material2 = new THREE.ShaderMaterial({ uniforms, vertexShader: PUFF_VERTEX, fragmentShader: PUFF_FRAGMENT, transparent: true, depthWrite: false });
|
|
8865
8874
|
const mesh2 = new THREE.Mesh(geometry, material2);
|
|
8866
8875
|
mesh2.name = "vfx-puffs";
|
|
8867
8876
|
mesh2.frustumCulled = false;
|