@woosh/meep-engine 2.40.1 → 2.41.0
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/core/collection/HashMap.d.ts +2 -0
- package/core/collection/HashMap.js +22 -0
- package/core/geom/3d/normal/hemioct/encode_unit3_hemioct.js +5 -0
- package/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +31 -0
- package/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +33 -0
- package/core/geom/3d/normal/octahedron/encoding.spec.js +29 -0
- package/core/geom/3d/topology/struct/BinaryTopology.js +112 -0
- package/core/math/sign_not_zero.js +8 -0
- package/core/parser/simple/SimpleParser.js +3 -86
- package/core/parser/simple/readUnsignedInteger.js +66 -0
- package/core/parser/simple/skipWhitespace.js +21 -0
- package/engine/EngineHarness.js +4 -0
- package/engine/asset/AssetDescription.spec.js +27 -0
- package/engine/asset/loaders/GLTFAssetLoader.js +5 -3
- package/engine/ecs/foliage/ImpostorFoliage.js +4 -0
- package/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +22 -7
- package/engine/graphics/filter/ImageFilter.js +2 -1
- package/engine/graphics/geometry/MikkT/MikkTSpace.spec.js +7 -1
- package/engine/{asset/loaders/geometry/geometry → graphics/geometry/buffered}/computeBufferAttributeHash.js +1 -1
- package/engine/{asset/loaders/geometry/geometry → graphics/geometry/buffered}/computeGeometryEquality.js +2 -2
- package/engine/{asset/loaders/geometry/geometry → graphics/geometry/buffered}/computeGeometryHash.js +1 -1
- package/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +2 -2
- package/engine/graphics/impostors/card_cluster/FacePlaneAssignment.js +30 -0
- package/engine/graphics/impostors/card_cluster/README.md +13 -0
- package/engine/graphics/impostors/octahedral/ImpostorBaker.js +332 -0
- package/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +10 -0
- package/engine/graphics/impostors/octahedral/ImpostorDescription.js +63 -0
- package/engine/graphics/impostors/octahedral/README.md +29 -0
- package/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere.js +42 -0
- package/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +88 -0
- package/engine/graphics/impostors/octahedral/grid/HemiOctahedralUvEncoder.js +20 -0
- package/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +25 -0
- package/engine/graphics/impostors/octahedral/grid/UvEncoder.js +21 -0
- package/engine/graphics/impostors/octahedral/prototypeBaker.js +138 -0
- package/engine/graphics/impostors/octahedral/shader/BakeShaderStandard.js +157 -0
- package/engine/graphics/impostors/octahedral/shader/ImpostorShaderStandard.js +306 -0
- package/engine/graphics/impostors/octahedral/shader/glsl/common.glsl +206 -0
- package/engine/graphics/micron/convert_three_object_to_micron.js +2 -2
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +2 -2
- package/engine/graphics/particles/node-based/codegen/CodeGenerator.js +1 -1
- package/engine/graphics/particles/node-based/nodes/noise/CurlNoiseNode.js +1 -1
- package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +32 -10
- package/engine/graphics/shaders/ScreenSpaceQuadShader.js +4 -14
- package/engine/graphics/shaders/glsl_gen_swizzled_read.js +39 -0
- package/engine/ui/GUIEngine.js +8 -1
- package/package.json +1 -1
- package/view/tooltip/gml/parser/readReferenceToken.js +1 -1
- package/engine/asset/GameAssetManager.js +0 -137
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
struct ImposterData
|
|
2
|
+
{
|
|
3
|
+
vec2 uv;
|
|
4
|
+
vec2 grid;
|
|
5
|
+
vec4 frame0;
|
|
6
|
+
vec4 frame1;
|
|
7
|
+
vec4 frame2;
|
|
8
|
+
vec4 vertex;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
struct Ray
|
|
12
|
+
{
|
|
13
|
+
vec3 Origin;
|
|
14
|
+
vec3 Direction;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//for hemisphere
|
|
18
|
+
vec3 OctaHemiEnc(vec2 coord)
|
|
19
|
+
{
|
|
20
|
+
coord = vec2(coord.x + coord.y, coord.x - coord.y) * 0.5;
|
|
21
|
+
vec3 vec = vec3(coord.x, 1.0 - dot(vec2(1.0, 1.0), abs(coord.xy)), coord.y);
|
|
22
|
+
return vec;
|
|
23
|
+
}
|
|
24
|
+
//for sphere
|
|
25
|
+
vec3 OctaSphereEnc(vec2 coord)
|
|
26
|
+
{
|
|
27
|
+
vec3 vec = vec3(coord.x, 1.0 - dot(vec2(1.0), abs(coord)), coord.y);
|
|
28
|
+
if (vec.y < 0.0)
|
|
29
|
+
{
|
|
30
|
+
vec2 flip = vec.xz >= 0.0 ? vec2(1.0, 1.0) : vec2(-1.0, -1.0);
|
|
31
|
+
vec.xz = (1-abs(vec.zx)) * flip;
|
|
32
|
+
}
|
|
33
|
+
return vec;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
vec3 GridToVector(vec2 coord)
|
|
37
|
+
{
|
|
38
|
+
vec3 vec;
|
|
39
|
+
if (_ImposterFullSphere)
|
|
40
|
+
{
|
|
41
|
+
vec = OctaSphereEnc(coord);
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
{
|
|
45
|
+
vec = OctaHemiEnc(coord);
|
|
46
|
+
}
|
|
47
|
+
return vec;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//for hemisphere
|
|
51
|
+
vec2 VecToHemiOct(vec3 vec)
|
|
52
|
+
{
|
|
53
|
+
vec.xz /= dot(1.0, abs(vec));
|
|
54
|
+
return vec2(vec.x + vec.z, vec.x - vec.z);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
vec2 VecToSphereOct(vec3 vec)
|
|
58
|
+
{
|
|
59
|
+
vec.xz /= dot(1, abs(vec));
|
|
60
|
+
if (vec.y <= 0)
|
|
61
|
+
{
|
|
62
|
+
vec2 flip = vec.xz >= 0 ? vec2(1, 1) : vec2(-1, -1);
|
|
63
|
+
vec.xz = (1-abs(vec.zx)) * flip;
|
|
64
|
+
}
|
|
65
|
+
return vec.xz;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
vec2 VectorToGrid(vec3 vec)
|
|
69
|
+
{
|
|
70
|
+
vec2 coord;
|
|
71
|
+
|
|
72
|
+
if (_ImposterFullSphere)
|
|
73
|
+
{
|
|
74
|
+
coord = VecToSphereOct(vec);
|
|
75
|
+
}
|
|
76
|
+
else
|
|
77
|
+
{
|
|
78
|
+
vec.y = max(0.001, vec.y);
|
|
79
|
+
vec = normalize(vec);
|
|
80
|
+
coord = VecToHemiOct(vec);
|
|
81
|
+
}
|
|
82
|
+
return coord;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
vec3 SpriteProjection(vec3 pivotToCameraRayLocal, float frames, vec2 size, vec2 coord){
|
|
86
|
+
vec3 gridVec = pivotToCameraRayLocal;
|
|
87
|
+
|
|
88
|
+
//octahedron vector, pivot to camera
|
|
89
|
+
vec3 y = normalize(gridVec);
|
|
90
|
+
|
|
91
|
+
vec3 x = normalize(cross(y, vec3(0.0, 1.0, 0.0)));
|
|
92
|
+
vec3 z = normalize(cross(x, y));
|
|
93
|
+
|
|
94
|
+
vec2 uv = ((coord*frames)-0.5) * 2.0;//-1 to 1
|
|
95
|
+
|
|
96
|
+
vec3 newX = x * uv.x;
|
|
97
|
+
vec3 newZ = z * uv.y;
|
|
98
|
+
|
|
99
|
+
vec2 halfSize = size*0.5;
|
|
100
|
+
|
|
101
|
+
newX *= halfSize.x;
|
|
102
|
+
newZ *= halfSize.y;
|
|
103
|
+
|
|
104
|
+
vec3 res = newX + newZ;
|
|
105
|
+
|
|
106
|
+
return res;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
vec4 TriangleInterpolate(vec2 uv){
|
|
110
|
+
uv = frac(uv);
|
|
111
|
+
|
|
112
|
+
vec2 omuv = vec2(1.0, 1.0) - uv.xy;
|
|
113
|
+
|
|
114
|
+
vec4 res = vec4(0, 0, 0, 0);
|
|
115
|
+
//frame 0
|
|
116
|
+
res.x = min(omuv.x, omuv.y);
|
|
117
|
+
//frame 1
|
|
118
|
+
res.y = abs(dot(uv, vec2(1.0, -1.0)));
|
|
119
|
+
//frame 2
|
|
120
|
+
res.z = min(uv.x, uv.y);
|
|
121
|
+
//mask
|
|
122
|
+
res.w = saturate(ceil(uv.x-uv.y));
|
|
123
|
+
|
|
124
|
+
return res;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//frame and framecout, returns
|
|
128
|
+
vec3 FrameXYToRay(vec2 frame, vec2 frameCountMinusOne)
|
|
129
|
+
{
|
|
130
|
+
//divide frame x y by framecount minus one to get 0-1
|
|
131
|
+
vec2 f = frame.xy / frameCountMinusOne;
|
|
132
|
+
|
|
133
|
+
//bias and scale to -1 to 1
|
|
134
|
+
f = (f-0.5)*2.0;
|
|
135
|
+
|
|
136
|
+
//convert to vector, either full sphere or hemi sphere
|
|
137
|
+
vec3 vec = GridToVector(f);
|
|
138
|
+
|
|
139
|
+
vec = normalize(vec);
|
|
140
|
+
|
|
141
|
+
return vec;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
vec3 ITBasis(vec3 vec, vec3 basedX, vec3 basedY, vec3 basedZ)
|
|
145
|
+
{
|
|
146
|
+
return vec3(dot(basedX, vec), dot(basedY, vec), dot(basedZ, vec));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
vec3 FrameTransform(vec3 projRay, vec3 frameRay, out vec3 worldX, out vec3 worldZ)
|
|
150
|
+
{
|
|
151
|
+
//TODO something might be wrong here
|
|
152
|
+
worldX = normalize(vec3(-frameRay.z, 0, frameRay.x));
|
|
153
|
+
worldZ = normalize(cross(worldX, frameRay));
|
|
154
|
+
|
|
155
|
+
projRay *= -1.0;
|
|
156
|
+
|
|
157
|
+
vec3 local = normalize(ITBasis(projRay, worldX, frameRay, worldZ));
|
|
158
|
+
return local;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
vec4 ImposterBlendWeights(sampler2D tex, vec2 uv, vec2 frame0, vec2 frame1, vec2 frame2, vec4 weights, vec2 ddxy)
|
|
163
|
+
{
|
|
164
|
+
vec4 samp0 = tex2Dgrad(tex, frame0, ddxy.x, ddxy.y);
|
|
165
|
+
vec4 samp1 = tex2Dgrad(tex, frame1, ddxy.x, ddxy.y);
|
|
166
|
+
vec4 samp2 = tex2Dgrad(tex, frame2, ddxy.x, ddxy.y);
|
|
167
|
+
|
|
168
|
+
//vec4 samp0 = tex2Dlod( tex, float4(frame0,0,0) );
|
|
169
|
+
//vec4 samp1 = tex2Dlod( tex, float4(frame1,0,0) );
|
|
170
|
+
//vec4 samp2 = tex2Dlod( tex, float4(frame2,0,0) );
|
|
171
|
+
|
|
172
|
+
vec4 result = samp0*weights.x + samp1*weights.y + samp2*weights.z;
|
|
173
|
+
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
vec2 VirtualPlaneUV(vec3 planeNormal, vec3 planeX, vec3 planeZ, vec3 center, vec2 uvScale, Ray rayLocal){
|
|
178
|
+
float normalDotOrigin = dot(planeNormal, rayLocal.Origin);
|
|
179
|
+
float normalDotCenter = dot(planeNormal, center);
|
|
180
|
+
float normalDotRay = dot(planeNormal, rayLocal.Direction);
|
|
181
|
+
|
|
182
|
+
float planeDistance = normalDotOrigin-normalDotCenter;
|
|
183
|
+
planeDistance *= -1.0;
|
|
184
|
+
|
|
185
|
+
float intersect = planeDistance / normalDotRay;
|
|
186
|
+
|
|
187
|
+
vec3 intersection = ((rayLocal.Direction * intersect) + rayLocal.Origin) - center;
|
|
188
|
+
|
|
189
|
+
float dx = dot(planeX, intersection);
|
|
190
|
+
float dz = dot(planeZ, intersection);
|
|
191
|
+
|
|
192
|
+
vec2 uv = vec2(0, 0);
|
|
193
|
+
|
|
194
|
+
if (intersect > 0)
|
|
195
|
+
{
|
|
196
|
+
uv = vec2(dx, dz);
|
|
197
|
+
}
|
|
198
|
+
else
|
|
199
|
+
{
|
|
200
|
+
uv = vec2(0, 0);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
uv /= uvScale;
|
|
204
|
+
uv += vec2(0.5, 0.5);
|
|
205
|
+
return uv;
|
|
206
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HashMap } from "../../../core/collection/HashMap.js";
|
|
2
|
-
import { computeGeometryHash } from "
|
|
3
|
-
import { computeGeometryEquality } from "
|
|
2
|
+
import { computeGeometryHash } from "../geometry/buffered/computeGeometryHash.js";
|
|
3
|
+
import { computeGeometryEquality } from "../geometry/buffered/computeGeometryEquality.js";
|
|
4
4
|
import { buildMicronGeometryFromBufferGeometry } from "./build/buildMicronGeometryFromBufferGeometry.js";
|
|
5
5
|
import { ThreeMicronMesh } from "./format/ThreeMicronMesh.js";
|
|
6
6
|
import { AsyncMapWrapper } from "../../../core/collection/map/AsyncMapWrapper.js";
|
|
@@ -3,8 +3,8 @@ import { VGThreeRenderer } from "../render/v1/VGThreeRenderer.js";
|
|
|
3
3
|
import { RenderLayer } from "../../render/layers/RenderLayer.js";
|
|
4
4
|
import { RenderPassType } from "../../render/RenderPassType.js";
|
|
5
5
|
import { Cache } from "../../../../core/cache/Cache.js";
|
|
6
|
-
import { computeGeometryHash } from "
|
|
7
|
-
import { computeGeometryEquality } from "
|
|
6
|
+
import { computeGeometryHash } from "../../geometry/buffered/computeGeometryHash.js";
|
|
7
|
+
import { computeGeometryEquality } from "../../geometry/buffered/computeGeometryEquality.js";
|
|
8
8
|
import { CachedAsyncMap } from "../../../../core/collection/map/CachedAsyncMap.js";
|
|
9
9
|
import { AsyncRemoteHashMap } from "../../../../core/collection/map/AsyncRemoteHashMap.js";
|
|
10
10
|
import { BufferGeometrySerializationAdapter } from "./serialization/BufferGeometrySerializationAdapter.js";
|
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
} from "three";
|
|
12
12
|
import CheckersTexture from "../../../texture/CheckersTexture.js";
|
|
13
13
|
import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../../../geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js";
|
|
14
|
+
import { formatToChannelCount } from "../../../texture/formatToChannelCount.js";
|
|
15
|
+
import { glsl_gen_swizzled_read } from "../../../shaders/glsl_gen_swizzled_read.js";
|
|
16
|
+
import { assert } from "../../../../../core/assert.js";
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -44,8 +47,19 @@ function sampleTexel(texture, name, uv) {
|
|
|
44
47
|
/**
|
|
45
48
|
*
|
|
46
49
|
* @param {THREE.Texture} texture
|
|
50
|
+
* @param {number} [alpha_override] will force specified alpha value in output, useful for cases where alpha would be 0 otherwise
|
|
51
|
+
* @param {(string|number)[]} swizzle allows us to re-arrange pixels as they are being written out
|
|
47
52
|
*/
|
|
48
|
-
function makeShader(texture) {
|
|
53
|
+
function makeShader({ texture, alpha_override, swizzle }) {
|
|
54
|
+
let _swizzle = swizzle.slice();
|
|
55
|
+
|
|
56
|
+
const texture_channel_count = formatToChannelCount(texture.format);
|
|
57
|
+
|
|
58
|
+
if (texture_channel_count < 4) {
|
|
59
|
+
// no override specified, and alpha would be 0, force it to one to make image visible
|
|
60
|
+
_swizzle[4] = 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
49
63
|
return new ShaderMaterial({
|
|
50
64
|
|
|
51
65
|
vertexShader: /* glsl */`
|
|
@@ -68,11 +82,7 @@ function makeShader(texture) {
|
|
|
68
82
|
void main() {
|
|
69
83
|
|
|
70
84
|
vec4 texel = ${sampleTexel(texture, 'tDiffuse', 'vUv')};
|
|
71
|
-
gl_FragColor = texel;
|
|
72
|
-
|
|
73
|
-
gl_FragColor.a = 1.0;
|
|
74
|
-
// gl_FragColor.r *= 255.0;
|
|
75
|
-
|
|
85
|
+
gl_FragColor = ${glsl_gen_swizzled_read('texel', swizzle)};
|
|
76
86
|
}`,
|
|
77
87
|
uniforms: {
|
|
78
88
|
|
|
@@ -88,7 +98,8 @@ function makeShader(texture) {
|
|
|
88
98
|
* @param {number} width
|
|
89
99
|
* @param {THREE.Texture} texture
|
|
90
100
|
* @param {THREE.WebGLRenderer} renderer
|
|
91
|
-
* @param flipY
|
|
101
|
+
* @param {boolean} [flipY]
|
|
102
|
+
* @param {(string|number)[]} [swizzle]
|
|
92
103
|
* @return {{view: View, render: function}}
|
|
93
104
|
*/
|
|
94
105
|
export function buildCanvasViewFromTexture({
|
|
@@ -96,9 +107,18 @@ export function buildCanvasViewFromTexture({
|
|
|
96
107
|
width = texture.image.width,
|
|
97
108
|
height = texture.image.height,
|
|
98
109
|
renderer,
|
|
99
|
-
flipY = true
|
|
110
|
+
flipY = true,
|
|
111
|
+
swizzle = ['r', 'g', 'b', 'a']
|
|
100
112
|
}) {
|
|
113
|
+
|
|
114
|
+
assert.isArray(swizzle, 'swizzle');
|
|
115
|
+
|
|
101
116
|
const canvasView = new CanvasView();
|
|
117
|
+
canvasView.css({
|
|
118
|
+
position: 'absolute',
|
|
119
|
+
left: 0,
|
|
120
|
+
top: 0
|
|
121
|
+
});
|
|
102
122
|
canvasView.size.set(width, height);
|
|
103
123
|
|
|
104
124
|
const ctx = canvasView.context2d;
|
|
@@ -137,7 +157,7 @@ export function buildCanvasViewFromTexture({
|
|
|
137
157
|
*/
|
|
138
158
|
function getShader() {
|
|
139
159
|
if (__texture_cached !== texture || copyShader === null) {
|
|
140
|
-
copyShader = makeShader(texture);
|
|
160
|
+
copyShader = makeShader({ texture: texture, swizzle });
|
|
141
161
|
|
|
142
162
|
copyShader.side = DoubleSide;
|
|
143
163
|
copyShader.uniforms.tDiffuse.value = texture;
|
|
@@ -154,6 +174,8 @@ export function buildCanvasViewFromTexture({
|
|
|
154
174
|
|
|
155
175
|
getShader().uniforms.tDiffuse.value = texture;
|
|
156
176
|
|
|
177
|
+
const _rt = renderer.getRenderTarget();
|
|
178
|
+
|
|
157
179
|
renderer.setRenderTarget(renderTarget);
|
|
158
180
|
|
|
159
181
|
renderer.render(scene, camera);
|
|
@@ -163,7 +185,7 @@ export function buildCanvasViewFromTexture({
|
|
|
163
185
|
|
|
164
186
|
ctx.putImageData(imageData, 0, 0)
|
|
165
187
|
|
|
166
|
-
renderer.setRenderTarget(
|
|
188
|
+
renderer.setRenderTarget(_rt);
|
|
167
189
|
};
|
|
168
190
|
|
|
169
191
|
return {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { glsl_gen_swizzled_read } from "./glsl_gen_swizzled_read.js";
|
|
2
|
+
|
|
1
3
|
function vertexShader() {
|
|
2
4
|
return `
|
|
3
5
|
varying vec2 vUv;
|
|
@@ -11,25 +13,13 @@ function vertexShader() {
|
|
|
11
13
|
`;
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
|
|
14
17
|
/**
|
|
15
18
|
*
|
|
16
19
|
* @param {string[]} [swizzle] what to read from the texture
|
|
17
20
|
* @returns {string}
|
|
18
21
|
*/
|
|
19
22
|
function fragmentShader(swizzle = ['r', 'g', 'b', 'a']) {
|
|
20
|
-
const swizzle_read = [];
|
|
21
|
-
const n = swizzle.length;
|
|
22
|
-
for (let i = 0; i < n; i++) {
|
|
23
|
-
const token = swizzle[i];
|
|
24
|
-
|
|
25
|
-
if (typeof token === "string") {
|
|
26
|
-
swizzle_read[i] = `texel.${token}`;
|
|
27
|
-
} else if (typeof token === "number") {
|
|
28
|
-
swizzle_read[i] = Number(token).toFixed(4);
|
|
29
|
-
} else {
|
|
30
|
-
throw new Error(`Unsupported swizzle token '${token}'`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
23
|
|
|
34
24
|
return `
|
|
35
25
|
uniform sampler2D tTexture;
|
|
@@ -37,7 +27,7 @@ function fragmentShader(swizzle = ['r', 'g', 'b', 'a']) {
|
|
|
37
27
|
|
|
38
28
|
void main(){
|
|
39
29
|
vec4 texel = texture2D( tTexture, vUv );
|
|
40
|
-
gl_FragColor =
|
|
30
|
+
gl_FragColor = ${glsl_gen_swizzled_read('texel', swizzle)};
|
|
41
31
|
}
|
|
42
32
|
`;
|
|
43
33
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {string} input name of the variable on which components are being accessed
|
|
4
|
+
* @param {(string|number)[]} swizzle
|
|
5
|
+
* @returns {string} swizzled vector
|
|
6
|
+
*/
|
|
7
|
+
export function glsl_gen_swizzled_read(input, swizzle) {
|
|
8
|
+
const swizzle_read = [];
|
|
9
|
+
const n = swizzle.length;
|
|
10
|
+
for (let i = 0; i < n; i++) {
|
|
11
|
+
const token = swizzle[i];
|
|
12
|
+
|
|
13
|
+
if (typeof token === "string") {
|
|
14
|
+
swizzle_read[i] = `${input}.${token}`;
|
|
15
|
+
} else if (typeof token === "number") {
|
|
16
|
+
swizzle_read[i] = Number(token).toFixed(4);
|
|
17
|
+
} else {
|
|
18
|
+
throw new Error(`Unsupported swizzle token '${token}'`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const arg_string = swizzle_read.join(', ');
|
|
23
|
+
|
|
24
|
+
const ctors = [
|
|
25
|
+
undefined,
|
|
26
|
+
'float',
|
|
27
|
+
'vec2',
|
|
28
|
+
'vec3',
|
|
29
|
+
'vec4'
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const ctor = ctors[swizzle.length];
|
|
33
|
+
|
|
34
|
+
if (ctor === undefined) {
|
|
35
|
+
throw new Error(`No constructor for input length ${swizzle.length}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return `${ctor}(${arg_string})`;
|
|
39
|
+
}
|
package/engine/ui/GUIEngine.js
CHANGED
|
@@ -103,7 +103,14 @@ function GUIEngine() {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
this.view = new EmptyView({
|
|
106
|
+
this.view = new EmptyView({
|
|
107
|
+
classList: ['gui-engine-root'],
|
|
108
|
+
css: {
|
|
109
|
+
position: "absolute",
|
|
110
|
+
left: "0",
|
|
111
|
+
top: "0"
|
|
112
|
+
}
|
|
113
|
+
});
|
|
107
114
|
|
|
108
115
|
/**
|
|
109
116
|
*
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.41.0",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import ParserError from "../../../../core/parser/simple/ParserError.js";
|
|
2
|
-
import { skipWhitespace } from "../../../../core/parser/simple/SimpleParser.js";
|
|
3
2
|
import { readReferenceValueToken } from "./readReferenceValueToken.js";
|
|
4
3
|
import { TooltipReferenceValue } from "./TooltipReferenceValue.js";
|
|
5
4
|
import Token from "../../../../core/parser/simple/Token.js";
|
|
6
5
|
import { TooltipTokenType } from "./TooltipTokenType.js";
|
|
6
|
+
import { skipWhitespace } from "../../../../core/parser/simple/skipWhitespace.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 03/09/2014.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { sRGBEncoding, TextureLoader as ThreeTextureLoader } from "three";
|
|
6
|
-
|
|
7
|
-
import { Asset } from "./Asset.js";
|
|
8
|
-
import { computeFileExtension } from "../../core/FilePath.js";
|
|
9
|
-
import { DDSLoader } from "three/examples/jsm/loaders/DDSLoader.js";
|
|
10
|
-
import { ArrayBufferLoader } from "./loaders/ArrayBufferLoader.js";
|
|
11
|
-
import { JsonAssetLoader } from "./loaders/JsonAssetLoader.js";
|
|
12
|
-
import { GameAssetType } from "./GameAssetType.js";
|
|
13
|
-
import { TextAssetLoader } from "./loaders/TextAssetLoader.js";
|
|
14
|
-
import { AnimationGraphDefinitionAssetLoader } from "../graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionAssetLoader.js";
|
|
15
|
-
import { JavascriptAssetLoader } from "./loaders/JavascriptAssetLoader.js";
|
|
16
|
-
import { ImageRGBADataLoader } from "./loaders/image/ImageRGBADataLoader.js";
|
|
17
|
-
import { GLTFAssetLoader } from "./loaders/GLTFAssetLoader.js";
|
|
18
|
-
import { SVGAssetLoader } from "./loaders/SVGAssetLoader.js";
|
|
19
|
-
import { AttachmentSocketsAssetLoader } from "../ecs/sockets/serialization/AttachmentSocketsAssetLoader.js";
|
|
20
|
-
import { FontAssetLoader } from "../../core/font/FontAssetLoader.js";
|
|
21
|
-
import { computeTextureByteSize } from "./loaders/texture/loadStandardImageTexture.js";
|
|
22
|
-
import { TextureAssetLoader } from "./loaders/texture/TextureAssetLoader.js";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const textureLoader = new ThreeTextureLoader();
|
|
26
|
-
const ddsLoader = new DDSLoader();
|
|
27
|
-
|
|
28
|
-
export function deferredTextureLoader(path, success, failure, progress) {
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param {Texture} texture
|
|
33
|
-
*/
|
|
34
|
-
function handleLoad(texture) {
|
|
35
|
-
const byteSize = computeTextureByteSize(texture);
|
|
36
|
-
|
|
37
|
-
asset.byteSize = byteSize;
|
|
38
|
-
|
|
39
|
-
pending.forEach(p => {
|
|
40
|
-
p.image = texture.image;
|
|
41
|
-
p.mipmaps = texture.mipmaps;
|
|
42
|
-
|
|
43
|
-
p.format = texture.format;
|
|
44
|
-
|
|
45
|
-
p.needsUpdate = true;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
isLoaded = true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function loadCompressed() {
|
|
52
|
-
const texture = ddsLoader.load(path, handleLoad, progress, failure);
|
|
53
|
-
|
|
54
|
-
if (texture.mipmaps === undefined) {
|
|
55
|
-
texture.mipmaps = [];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return texture;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const pending = [];
|
|
62
|
-
|
|
63
|
-
let isLoaded = false;
|
|
64
|
-
|
|
65
|
-
//figure out what kind of a texture it is
|
|
66
|
-
const fileExtension = computeFileExtension(path);
|
|
67
|
-
if (fileExtension === null) {
|
|
68
|
-
throw new Error(`no file extension on path '${path}'`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const lowerCaseExtension = fileExtension.toLowerCase();
|
|
72
|
-
|
|
73
|
-
let texture;
|
|
74
|
-
|
|
75
|
-
switch (lowerCaseExtension) {
|
|
76
|
-
case "dds":
|
|
77
|
-
texture = loadCompressed();
|
|
78
|
-
break;
|
|
79
|
-
case "png":
|
|
80
|
-
case "jpg":
|
|
81
|
-
texture = textureLoader.load(path, handleLoad, progress, failure);
|
|
82
|
-
break;
|
|
83
|
-
default:
|
|
84
|
-
throw new Error(`Unsupported texture file format: '${lowerCaseExtension}'`);
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
texture.encoding = sRGBEncoding;
|
|
89
|
-
|
|
90
|
-
const asset = new Asset(function () {
|
|
91
|
-
|
|
92
|
-
const clone = texture.clone();
|
|
93
|
-
|
|
94
|
-
if (isLoaded) {
|
|
95
|
-
clone.needsUpdate = true;
|
|
96
|
-
} else {
|
|
97
|
-
pending.push(clone);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return clone;
|
|
101
|
-
}, 1);
|
|
102
|
-
|
|
103
|
-
success(asset);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
* @param {AssetManager} assetManager
|
|
110
|
-
*/
|
|
111
|
-
function initAssetManager(assetManager) {
|
|
112
|
-
|
|
113
|
-
assetManager.registerLoader(GameAssetType.ModelGLTF, new GLTFAssetLoader());
|
|
114
|
-
assetManager.registerLoader(GameAssetType.ModelGLTF_JSON, new GLTFAssetLoader());
|
|
115
|
-
assetManager.registerLoader(GameAssetType.ArrayBuffer, new ArrayBufferLoader());
|
|
116
|
-
assetManager.registerLoader(GameAssetType.Texture, new TextureAssetLoader());
|
|
117
|
-
assetManager.registerLoader(GameAssetType.DeferredTexture, deferredTextureLoader);
|
|
118
|
-
|
|
119
|
-
assetManager.registerLoader(GameAssetType.JSON, new JsonAssetLoader());
|
|
120
|
-
assetManager.registerLoader(GameAssetType.Text, new TextAssetLoader());
|
|
121
|
-
|
|
122
|
-
assetManager.registerLoader(GameAssetType.JavaScript, new JavascriptAssetLoader());
|
|
123
|
-
|
|
124
|
-
assetManager.registerLoader(GameAssetType.Font, new FontAssetLoader());
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
assetManager.registerLoader(GameAssetType.AnimationGraph, new AnimationGraphDefinitionAssetLoader());
|
|
128
|
-
assetManager.registerLoader(GameAssetType.AttachmentSockets, new AttachmentSocketsAssetLoader());
|
|
129
|
-
|
|
130
|
-
assetManager.registerLoader(GameAssetType.Image, new ImageRGBADataLoader());
|
|
131
|
-
|
|
132
|
-
assetManager.registerLoader(GameAssetType.ImageSvg, new SVGAssetLoader());
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export {
|
|
136
|
-
initAssetManager
|
|
137
|
-
};
|