phoria2 1.0.0 → 1.1.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/README.md +6 -6
- package/dist/bloom.js +4 -4
- package/dist/bloom.js.map +1 -1
- package/dist/charts.js +377 -377
- package/dist/charts.js.map +1 -1
- package/dist/core.js +1052 -558
- package/dist/core.js.map +1 -1
- package/dist/edit.js +48 -48
- package/dist/edit.js.map +1 -1
- package/dist/explain.js +1 -1
- package/dist/gltf.js +207 -162
- package/dist/gltf.js.map +1 -1
- package/dist/motion.js +27 -27
- package/dist/motion.js.map +1 -1
- package/dist/particles.js +50 -50
- package/dist/particles.js.map +1 -1
- package/dist/passes.js +199 -97
- package/dist/passes.js.map +1 -1
- package/dist/phoria2.js +1 -1
- package/dist/picking.js +16 -21
- package/dist/picking.js.map +1 -1
- package/dist/snapshot.js +1 -1
- package/dist/tooltip.js +3 -3
- package/dist/tooltip.js.map +1 -1
- package/dist/types/View.d.ts +5 -0
- package/dist/types/geometry/Geometry.d.ts +6 -0
- package/dist/types/material/Material.d.ts +125 -0
- package/dist/types/material/Texture.d.ts +37 -5
- package/dist/types/webgl/WebGLRenderer.d.ts +6 -0
- package/dist/types/webgl/passes.d.ts +37 -13
- package/dist/types/webgl/resources.d.ts +24 -2
- package/dist/types/webgl/shaders.d.ts +4 -2
- package/llms-full.txt +96 -7
- package/package.json +1 -1
- package/schema/scene.schema.json +127 -0
- package/src/View.js +4 -2
- package/src/geometry/Geometry.js +8 -1
- package/src/gltf/load.js +50 -6
- package/src/material/Material.js +104 -19
- package/src/material/Texture.js +116 -11
- package/src/watch.js +19 -0
- package/src/webgl/WebGLRenderer.js +51 -12
- package/src/webgl/passes.js +190 -32
- package/src/webgl/picking.js +0 -1
- package/src/webgl/resources.js +89 -8
- package/src/webgl/shaders.js +350 -48
package/dist/passes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as e, D as t,
|
|
1
|
+
import { A as e, D as t, Ft as n, I as r, It as i, M as a, Nt as o, O as s, P as c, bt as l, j as u, k as d, vt as f, yt as p } from "./core.js";
|
|
2
2
|
// src/irradiance.js
|
|
3
|
-
function
|
|
3
|
+
function m({ data: e, width: t, height: n }) {
|
|
4
4
|
let r = /* @__PURE__ */ new Float64Array(27), i = Math.max(1, Math.floor(t / 128)), a = Math.max(1, Math.floor(n / 64)), o = 2 * Math.PI * i / t, s = Math.PI * a / n;
|
|
5
5
|
for (let c = 0; c < n; c += a) {
|
|
6
6
|
let l = (c + .5 * a) / n * Math.PI, u = Math.sin(l), d = Math.cos(l), f = o * s * u;
|
|
@@ -47,7 +47,7 @@ function p({ data: e, width: t, height: n }) {
|
|
|
47
47
|
return u;
|
|
48
48
|
}
|
|
49
49
|
// src/webgl/passes.js
|
|
50
|
-
var
|
|
50
|
+
var h = `precision highp float;
|
|
51
51
|
in vec2 vUv;
|
|
52
52
|
uniform mat4 uInverseViewProjection;
|
|
53
53
|
uniform vec3 uCameraPosition;
|
|
@@ -56,9 +56,9 @@ uniform float uLod;
|
|
|
56
56
|
uniform float uIntensity;
|
|
57
57
|
uniform int uHdr;
|
|
58
58
|
out vec4 fragColor;
|
|
59
|
-
${u}
|
|
60
59
|
${e}
|
|
61
|
-
${
|
|
60
|
+
${u}
|
|
61
|
+
${r}
|
|
62
62
|
void main() {
|
|
63
63
|
vec4 far = uInverseViewProjection * vec4(vUv * 2.0 - 1.0, 1.0, 1.0);
|
|
64
64
|
vec3 d = normalize(far.xyz / far.w - uCameraPosition);
|
|
@@ -66,14 +66,14 @@ vec3 c = textureLod(uBackground, equirectUv(d), uLod).rgb * uIntensity;
|
|
|
66
66
|
if (uHdr == 1) c = toneMap(c);
|
|
67
67
|
fragColor = vec4(linearToSrgb(c), 1.0);
|
|
68
68
|
}
|
|
69
|
-
`,
|
|
69
|
+
`, g = `precision highp float;
|
|
70
70
|
in vec2 vUv;
|
|
71
71
|
uniform sampler2D uSource;
|
|
72
72
|
uniform float uRoughness;
|
|
73
73
|
uniform float uSourceTexels;
|
|
74
74
|
uniform float uCopyLod;
|
|
75
75
|
out vec4 fragColor;
|
|
76
|
-
${
|
|
76
|
+
${u}
|
|
77
77
|
const float PI = 3.14159265359;
|
|
78
78
|
const uint SAMPLES = 192u;
|
|
79
79
|
vec2 hammersley(uint i) {
|
|
@@ -114,52 +114,122 @@ weight += NoL;
|
|
|
114
114
|
}
|
|
115
115
|
fragColor = vec4(sum / max(weight, 1e-4), 1.0);
|
|
116
116
|
}
|
|
117
|
-
`,
|
|
117
|
+
`, _ = `precision highp float;
|
|
118
118
|
in vec3 vWorldPosition;
|
|
119
119
|
uniform vec4 uMask;
|
|
120
120
|
out vec4 fragColor;
|
|
121
|
-
${
|
|
121
|
+
${s}
|
|
122
122
|
void main() {
|
|
123
123
|
clipAway(vWorldPosition);
|
|
124
124
|
fragColor = uMask;
|
|
125
125
|
}
|
|
126
|
-
`,
|
|
126
|
+
`, v = 16, y = `uniform sampler2D uSource;
|
|
127
127
|
uniform vec2 uStep;
|
|
128
128
|
uniform int uRadius;
|
|
129
129
|
vec4 widened(vec2 uv) {
|
|
130
130
|
vec4 best = vec4(0.0);
|
|
131
131
|
float nearest = 1e9;
|
|
132
|
-
for (int i = -${
|
|
132
|
+
for (int i = -${v}; i <= ${v}; i++) {
|
|
133
133
|
float d = abs(float(i));
|
|
134
134
|
if (d > float(uRadius)) continue;
|
|
135
135
|
vec4 s = texture(uSource, uv + uStep * float(i));
|
|
136
|
-
if (s.a > 0.0 && d <= s.a * ${
|
|
136
|
+
if (s.a > 0.0 && d <= s.a * ${v}.0 && d < nearest) {
|
|
137
137
|
best = s;
|
|
138
138
|
nearest = d;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
return best;
|
|
142
142
|
}
|
|
143
|
-
`,
|
|
143
|
+
`, b = `precision highp float;
|
|
144
144
|
in vec2 vUv;
|
|
145
145
|
out vec4 fragColor;
|
|
146
|
-
${
|
|
146
|
+
${y}
|
|
147
147
|
void main() {
|
|
148
148
|
fragColor = widened(vUv);
|
|
149
149
|
}
|
|
150
|
-
`,
|
|
150
|
+
`, x = `precision highp float;
|
|
151
151
|
in vec2 vUv;
|
|
152
152
|
uniform sampler2D uMask;
|
|
153
153
|
out vec4 fragColor;
|
|
154
|
-
${
|
|
155
|
-
${
|
|
154
|
+
${e}
|
|
155
|
+
${y}
|
|
156
156
|
void main() {
|
|
157
157
|
if (texture(uMask, vUv).a > 0.0) discard;
|
|
158
158
|
vec4 ring = widened(vUv);
|
|
159
159
|
if (ring.a <= 0.0) discard;
|
|
160
160
|
fragColor = vec4(linearToSrgb(ring.rgb), 1.0);
|
|
161
161
|
}
|
|
162
|
-
`,
|
|
162
|
+
`, S = `precision highp float;
|
|
163
|
+
in vec3 vWorldPosition;
|
|
164
|
+
uniform vec4 uMask;
|
|
165
|
+
layout(location = 0) out vec4 fragColor;
|
|
166
|
+
layout(location = 1) out vec4 fragCoverage;
|
|
167
|
+
${s}
|
|
168
|
+
void main() {
|
|
169
|
+
clipAway(vWorldPosition);
|
|
170
|
+
fragColor = uMask;
|
|
171
|
+
fragCoverage = vec4(1.0);
|
|
172
|
+
}
|
|
173
|
+
`, C = `uniform sampler2D uMask;
|
|
174
|
+
uniform sampler2D uCoverage;
|
|
175
|
+
uniform vec2 uTexel;
|
|
176
|
+
uniform int uRadius;
|
|
177
|
+
vec4 masked(vec2 uv, float coverage) {
|
|
178
|
+
vec4 m = texture(uMask, uv) / coverage;
|
|
179
|
+
return vec4(m.rgb, m.a * ${v}.0);
|
|
180
|
+
}
|
|
181
|
+
`, w = `precision highp float;
|
|
182
|
+
in vec2 vUv;
|
|
183
|
+
out vec4 fragColor;
|
|
184
|
+
${C}
|
|
185
|
+
void main() {
|
|
186
|
+
float nearest = 1e9;
|
|
187
|
+
int at = 0;
|
|
188
|
+
bool found = false;
|
|
189
|
+
for (int i = -17; i <= 17; i++) {
|
|
190
|
+
if (abs(i) > uRadius + 1) continue;
|
|
191
|
+
vec2 uv = vUv + vec2(float(i) * uTexel.x, 0.0);
|
|
192
|
+
float c = texture(uCoverage, uv).r;
|
|
193
|
+
if (c <= 0.0) continue;
|
|
194
|
+
float d = abs(float(i)) - (c - 0.5);
|
|
195
|
+
if (d < masked(uv, c).a + 0.5 && d < nearest) {
|
|
196
|
+
nearest = d;
|
|
197
|
+
at = i;
|
|
198
|
+
found = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
fragColor = found ? vec4(float(at + 32) / 255.0, 0.0, 0.0, 1.0) : vec4(0.0);
|
|
202
|
+
}
|
|
203
|
+
`, T = `precision highp float;
|
|
204
|
+
in vec2 vUv;
|
|
205
|
+
uniform sampler2D uNearest;
|
|
206
|
+
out vec4 fragColor;
|
|
207
|
+
${e}
|
|
208
|
+
${C}
|
|
209
|
+
void main() {
|
|
210
|
+
float here = texture(uCoverage, vUv).r;
|
|
211
|
+
if (here >= 1.0) discard;
|
|
212
|
+
float nearest = 1e9;
|
|
213
|
+
vec4 ring = vec4(0.0);
|
|
214
|
+
for (int j = -17; j <= 17; j++) {
|
|
215
|
+
if (abs(j) > uRadius + 1) continue;
|
|
216
|
+
vec2 row = vUv + vec2(0.0, float(j) * uTexel.y);
|
|
217
|
+
vec4 n = texture(uNearest, row);
|
|
218
|
+
if (n.a <= 0.0) continue;
|
|
219
|
+
int i = int(n.r * 255.0 + 0.5) - 32;
|
|
220
|
+
vec2 uv = row + vec2(float(i) * uTexel.x, 0.0);
|
|
221
|
+
float c = texture(uCoverage, uv).r;
|
|
222
|
+
float d = length(vec2(float(i), float(j))) - (c - 0.5);
|
|
223
|
+
if (d < nearest) {
|
|
224
|
+
nearest = d;
|
|
225
|
+
ring = masked(uv, c);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
float alpha = clamp(ring.a - nearest + 0.5, 0.0, 1.0) * (1.0 - here);
|
|
229
|
+
if (alpha <= 0.0) discard;
|
|
230
|
+
fragColor = vec4(linearToSrgb(ring.rgb) * alpha, alpha);
|
|
231
|
+
}
|
|
232
|
+
`, E = [c, _], D = [a, b], O = [a, x], k = [c, S], A = [a, w], j = [a, T], M = [c, d], N = [a, h], P = [a, g], F = 512, I = 6, L = class {
|
|
163
233
|
#e = /* @__PURE__ */ new WeakMap();
|
|
164
234
|
#t = null;
|
|
165
235
|
#n = null;
|
|
@@ -183,33 +253,33 @@ fragColor = vec4(linearToSrgb(ring.rgb), 1.0);
|
|
|
183
253
|
});
|
|
184
254
|
let r = e.image, i = this.#d(r.width, r.height, Math.floor(Math.log2(Math.max(r.width, r.height))) + 1);
|
|
185
255
|
n.texSubImage2D(n.TEXTURE_2D, 0, 0, 0, r.width, r.height, n.RGBA, n.FLOAT, r.data), n.generateMipmap(n.TEXTURE_2D);
|
|
186
|
-
let a = this.#d(
|
|
256
|
+
let a = this.#d(F, F / 2, I), o = this.programs.ready("prefilter", [], P);
|
|
187
257
|
n.useProgram(o.program), o.set("uSource", i), o.set("uSourceTexels", r.width * r.height);
|
|
188
258
|
let s = n.createFramebuffer();
|
|
189
259
|
n.bindFramebuffer(n.FRAMEBUFFER, s), n.disable(n.DEPTH_TEST), n.disable(n.BLEND), n.disable(n.CULL_FACE);
|
|
190
|
-
for (let e = 0; e <
|
|
191
|
-
let t =
|
|
260
|
+
for (let e = 0; e < I; e++) {
|
|
261
|
+
let t = F >> e;
|
|
192
262
|
n.framebufferTexture2D(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0, n.TEXTURE_2D, a, e), n.viewport(0, 0, t, t / 2), o.set("uRoughness", e / 5), o.set("uCopyLod", Math.max(0, Math.log2(r.width / t))), this.programs.drawFullscreen();
|
|
193
263
|
}
|
|
194
264
|
return n.bindFramebuffer(n.FRAMEBUFFER, null), n.deleteFramebuffer(s), n.enable(n.DEPTH_TEST), t = {
|
|
195
265
|
source: i,
|
|
196
266
|
prefiltered: a,
|
|
197
267
|
maxLod: 5,
|
|
198
|
-
sh:
|
|
268
|
+
sh: m(r),
|
|
199
269
|
version: e.version
|
|
200
270
|
}, this.#e.set(e, t), t;
|
|
201
271
|
}
|
|
202
|
-
background(e, t,
|
|
203
|
-
let
|
|
204
|
-
if (a && !
|
|
205
|
-
let c = this.programs.ready("background", [],
|
|
206
|
-
|
|
272
|
+
background(e, t, r) {
|
|
273
|
+
let i = this.gl, a = t.isHDR, s = a ? this.environment(t) : null;
|
|
274
|
+
if (a && !s) return;
|
|
275
|
+
let c = this.programs.ready("background", [], N);
|
|
276
|
+
i.useProgram(c.program);
|
|
207
277
|
let l = Math.min(Math.max(e.backgroundBlur, 0), 1);
|
|
208
|
-
|
|
278
|
+
s ? (c.set("uBackground", l > 0 ? s.prefiltered : s.source), c.set("uLod", l * s.maxLod), c.set("uIntensity", e.environment === t ? e.environmentIntensity : 1)) : (c.set("uBackground", this.resources.texture(t)), c.set("uLod", l * 6), c.set("uIntensity", 1)), c.set("uHdr", +!!a), c.set("uExposure", r.exposure), c.set("uToneMapping", r.toneMapping), c.set("uInverseViewProjection", n(o(), e.camera.viewProjection)), c.set("uCameraPosition", e.camera.position), i.disable(i.DEPTH_TEST), i.disable(i.BLEND), i.disable(i.CULL_FACE), i.depthMask(!1), this.programs.drawFullscreen(), i.depthMask(!0), i.enable(i.DEPTH_TEST);
|
|
209
279
|
}
|
|
210
280
|
shadowMap(e) {
|
|
211
281
|
let t = this.gl;
|
|
212
|
-
this.#t ??= this.#l(
|
|
282
|
+
this.#t ??= this.#l(p), t.bindFramebuffer(t.FRAMEBUFFER, this.#t.framebuffer), t.viewport(0, 0, p, p), this.#a(), this.#s(e.casters, e.viewProjection), this.#o();
|
|
213
283
|
let n = new Float32Array([
|
|
214
284
|
.5,
|
|
215
285
|
0,
|
|
@@ -233,16 +303,16 @@ fragColor = vec4(linearToSrgb(ring.rgb), 1.0);
|
|
|
233
303
|
sampler: "uShadowMap",
|
|
234
304
|
texture: this.#t.texture,
|
|
235
305
|
uniforms: {
|
|
236
|
-
uShadowMatrix:
|
|
237
|
-
uShadowTexel: 1 /
|
|
306
|
+
uShadowMatrix: i(/* @__PURE__ */ new Float32Array(16), n, e.viewProjection),
|
|
307
|
+
uShadowTexel: 1 / p,
|
|
238
308
|
uShadowBias: e.texelSize * 1.5
|
|
239
309
|
}
|
|
240
310
|
};
|
|
241
311
|
}
|
|
242
312
|
spotShadowMaps(e) {
|
|
243
313
|
let t = this.gl;
|
|
244
|
-
this.#n ??= this.#l(
|
|
245
|
-
let n = /* @__PURE__ */ new Float32Array(64),
|
|
314
|
+
this.#n ??= this.#l(l), t.bindFramebuffer(t.FRAMEBUFFER, this.#n.framebuffer), t.viewport(0, 0, l, l), this.#a();
|
|
315
|
+
let n = /* @__PURE__ */ new Float32Array(64), r = /* @__PURE__ */ new Float32Array(16), a = /* @__PURE__ */ new Float32Array(4), o = l / 2;
|
|
246
316
|
for (let s of e) {
|
|
247
317
|
let e = s.tile % 2, c = Math.floor(s.tile / 2);
|
|
248
318
|
t.viewport(e * o, c * o, o, o), this.#s(s.casters, s.viewProjection);
|
|
@@ -264,7 +334,7 @@ fragColor = vec4(linearToSrgb(ring.rgb), 1.0);
|
|
|
264
334
|
.5,
|
|
265
335
|
1
|
|
266
336
|
]);
|
|
267
|
-
n.set(
|
|
337
|
+
n.set(i(/* @__PURE__ */ new Float32Array(16), l, s.viewProjection), s.tile * 16), r.set([
|
|
268
338
|
e * .5,
|
|
269
339
|
c * .5,
|
|
270
340
|
e * .5 + .5,
|
|
@@ -277,16 +347,16 @@ fragColor = vec4(linearToSrgb(ring.rgb), 1.0);
|
|
|
277
347
|
texture: this.#n.texture,
|
|
278
348
|
uniforms: {
|
|
279
349
|
uSpotShadowMatrix: n,
|
|
280
|
-
uSpotShadowTile:
|
|
350
|
+
uSpotShadowTile: r,
|
|
281
351
|
uSpotShadowBias: a,
|
|
282
|
-
uSpotShadowTexel: 1 /
|
|
352
|
+
uSpotShadowTexel: 1 / l
|
|
283
353
|
}
|
|
284
354
|
};
|
|
285
355
|
}
|
|
286
356
|
pointShadowMap(e) {
|
|
287
357
|
let t = this.gl;
|
|
288
|
-
return this.#r ??= this.#u(
|
|
289
|
-
t.bindFramebuffer(t.FRAMEBUFFER, this.#r.framebuffers[n]), t.viewport(0, 0,
|
|
358
|
+
return this.#r ??= this.#u(f), e.faces.forEach((e, n) => {
|
|
359
|
+
t.bindFramebuffer(t.FRAMEBUFFER, this.#r.framebuffers[n]), t.viewport(0, 0, f, f), this.#a(), this.#s(e.casters, e.viewProjection);
|
|
290
360
|
}), this.#o(), {
|
|
291
361
|
define: "POINT_SHADOW",
|
|
292
362
|
sampler: "uPointShadowMap",
|
|
@@ -306,83 +376,115 @@ fragColor = vec4(linearToSrgb(ring.rgb), 1.0);
|
|
|
306
376
|
let e = this.gl;
|
|
307
377
|
e.disable(e.POLYGON_OFFSET_FILL), e.bindFramebuffer(e.FRAMEBUFFER, null);
|
|
308
378
|
}
|
|
309
|
-
#s(e,
|
|
310
|
-
let
|
|
311
|
-
for (let
|
|
312
|
-
let e =
|
|
313
|
-
|
|
314
|
-
let
|
|
315
|
-
|
|
316
|
-
let
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
let e =
|
|
320
|
-
|
|
321
|
-
e.repeat[0],
|
|
322
|
-
e.repeat[1],
|
|
323
|
-
e.offset[0],
|
|
324
|
-
e.offset[1]
|
|
325
|
-
] : [
|
|
326
|
-
1,
|
|
327
|
-
1,
|
|
328
|
-
0,
|
|
329
|
-
0
|
|
330
|
-
]), e && c.set("uMap", this.resources.texture(e)), s && c.set("uTriplanar", a.triplanar);
|
|
379
|
+
#s(e, n) {
|
|
380
|
+
let r = this.gl;
|
|
381
|
+
for (let i of e) {
|
|
382
|
+
let e = i.instances, a = e ? ["INSTANCED"] : [];
|
|
383
|
+
i.clip && a.push("CLIP");
|
|
384
|
+
let o = i.material, s = o.alphaTest > 0, c = s && !!o.map && o.triplanar > 0;
|
|
385
|
+
s && a.push("ALPHA_TEST", ...o.map ? ["MAP"] : [], ...c ? ["TRIPLANAR"] : []), s && o.map?.uvSet === 1 && i.geometry.uvs2 && a.push("UV2", "uMapSet vUv2");
|
|
386
|
+
let l = this.programs.ready("depth", a, M);
|
|
387
|
+
if (r.useProgram(l.program), l.set("uViewProjection", n), l.set("uModel", i.worldMatrix), i.clip && l.set("uClipPlane", i.clip.plane), s) {
|
|
388
|
+
l.set("uOpacity", o.opacity), l.set("uAlphaTest", o.alphaTest);
|
|
389
|
+
let e = o.map;
|
|
390
|
+
e && (l.set("uMapUv", t(e)), l.set("uMap", this.resources.texture(e))), c && l.set("uTriplanar", o.triplanar);
|
|
331
391
|
}
|
|
332
|
-
this.resources.drawTriangles(
|
|
392
|
+
this.resources.drawTriangles(i.geometry, e);
|
|
333
393
|
}
|
|
334
394
|
}
|
|
335
|
-
outlineMask(e, t, n, r, i) {
|
|
336
|
-
let
|
|
337
|
-
|
|
338
|
-
let
|
|
395
|
+
outlineMask(e, t, n, r, i, a) {
|
|
396
|
+
let o = this.gl, s = this.#c(n, r, a);
|
|
397
|
+
o.bindFramebuffer(o.FRAMEBUFFER, s.msaa ? s.msaa.framebuffer : s.mask.framebuffer), s.msaa && o.drawBuffers([o.COLOR_ATTACHMENT0, o.COLOR_ATTACHMENT1]), o.viewport(0, 0, n, r), o.clearColor(0, 0, 0, 0), o.clear(o.COLOR_BUFFER_BIT), o.disable(o.DEPTH_TEST), o.disable(o.BLEND), o.disable(o.CULL_FACE), o.depthMask(!1);
|
|
398
|
+
let c = 1;
|
|
339
399
|
for (let n of e) {
|
|
340
|
-
let e = Math.min(
|
|
341
|
-
|
|
400
|
+
let e = Math.min(v, Math.max(1, Math.round(n.width * i)));
|
|
401
|
+
c = Math.max(c, e);
|
|
342
402
|
for (let r of n.items) {
|
|
343
403
|
let i = r.instances ? ["INSTANCED"] : [];
|
|
344
404
|
r.clip && i.push("CLIP");
|
|
345
|
-
let
|
|
346
|
-
|
|
405
|
+
let s = a ? this.programs.ready("outline-cover", i, k) : this.programs.ready("outline-mask", i, E);
|
|
406
|
+
o.useProgram(s.program), s.set("uViewProjection", t.camera.viewProjection), s.set("uModel", r.worldMatrix), s.set("uMask", [
|
|
347
407
|
n.color[0],
|
|
348
408
|
n.color[1],
|
|
349
409
|
n.color[2],
|
|
350
|
-
e /
|
|
351
|
-
]), r.clip &&
|
|
410
|
+
e / v
|
|
411
|
+
]), r.clip && s.set("uClipPlane", r.clip.plane), this.resources.drawTriangles(r.geometry, r.instances);
|
|
352
412
|
}
|
|
353
413
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
414
|
+
if (s.msaa && s.coverage) {
|
|
415
|
+
o.bindFramebuffer(o.READ_FRAMEBUFFER, s.msaa.framebuffer);
|
|
416
|
+
for (let [e, t] of [[o.COLOR_ATTACHMENT0, s.mask], [o.COLOR_ATTACHMENT1, s.coverage]]) o.readBuffer(e), o.bindFramebuffer(o.DRAW_FRAMEBUFFER, t.framebuffer), o.blitFramebuffer(0, 0, n, r, 0, 0, n, r, o.COLOR_BUFFER_BIT, o.NEAREST);
|
|
417
|
+
}
|
|
418
|
+
if (o.bindFramebuffer(o.FRAMEBUFFER, s.wide.framebuffer), o.clear(o.COLOR_BUFFER_BIT), s.coverage) {
|
|
419
|
+
let e = this.programs.ready("outline-smooth-widen", [], A);
|
|
420
|
+
o.useProgram(e.program), e.set("uMask", s.mask.texture), e.set("uCoverage", s.coverage.texture), e.set("uTexel", [1 / n, 1 / r]), e.set("uRadius", c);
|
|
421
|
+
} else {
|
|
422
|
+
let e = this.programs.ready("outline-widen", [], D);
|
|
423
|
+
o.useProgram(e.program), e.set("uSource", s.mask.texture), e.set("uStep", [1 / n, 0]), e.set("uRadius", c);
|
|
424
|
+
}
|
|
425
|
+
return this.programs.drawFullscreen(), o.depthMask(!0), o.enable(o.DEPTH_TEST), o.bindFramebuffer(o.FRAMEBUFFER, null), {
|
|
426
|
+
mask: s.mask.texture,
|
|
427
|
+
wide: s.wide.texture,
|
|
428
|
+
coverage: s.coverage?.texture ?? null,
|
|
429
|
+
radius: c,
|
|
430
|
+
width: n,
|
|
431
|
+
height: r
|
|
360
432
|
};
|
|
361
433
|
}
|
|
362
|
-
outlineComposite(e
|
|
363
|
-
let
|
|
364
|
-
|
|
434
|
+
outlineComposite(e) {
|
|
435
|
+
let t = this.gl;
|
|
436
|
+
if (e.coverage) {
|
|
437
|
+
let n = this.programs.ready("outline-smooth-composite", [], j);
|
|
438
|
+
t.useProgram(n.program), n.set("uNearest", e.wide), n.set("uMask", e.mask), n.set("uCoverage", e.coverage), n.set("uTexel", [1 / e.width, 1 / e.height]), n.set("uRadius", e.radius);
|
|
439
|
+
} else {
|
|
440
|
+
let n = this.programs.ready("outline-composite", [], O);
|
|
441
|
+
t.useProgram(n.program), n.set("uSource", e.wide), n.set("uMask", e.mask), n.set("uStep", [0, 1 / e.height]), n.set("uRadius", e.radius);
|
|
442
|
+
}
|
|
443
|
+
t.disable(t.DEPTH_TEST), t.disable(t.CULL_FACE), t.depthMask(!1), t.enable(t.BLEND), t.blendFunc(t.ONE, t.ONE_MINUS_SRC_ALPHA), this.programs.drawFullscreen(), t.depthMask(!0), t.enable(t.DEPTH_TEST);
|
|
365
444
|
}
|
|
366
|
-
#c(e, t) {
|
|
367
|
-
let
|
|
368
|
-
if (
|
|
369
|
-
let
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
framebuffer
|
|
445
|
+
#c(e, t, n) {
|
|
446
|
+
let r = this.#i;
|
|
447
|
+
if (r && r.width === e && r.height === t && r.smooth === n) return r;
|
|
448
|
+
let i = this.gl;
|
|
449
|
+
if (r) {
|
|
450
|
+
for (let e of [
|
|
451
|
+
r.mask,
|
|
452
|
+
r.wide,
|
|
453
|
+
r.coverage
|
|
454
|
+
]) e && (i.deleteTexture(e.texture), i.deleteFramebuffer(e.framebuffer));
|
|
455
|
+
if (r.msaa) {
|
|
456
|
+
i.deleteFramebuffer(r.msaa.framebuffer);
|
|
457
|
+
for (let e of r.msaa.renderbuffers) i.deleteRenderbuffer(e);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
let a = (n = i.RGBA8) => {
|
|
461
|
+
let r = i.createTexture();
|
|
462
|
+
i.activeTexture(i.TEXTURE15), i.bindTexture(i.TEXTURE_2D, r), i.texStorage2D(i.TEXTURE_2D, 1, n, e, t), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, i.NEAREST), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, i.NEAREST), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE);
|
|
463
|
+
let a = i.createFramebuffer();
|
|
464
|
+
return i.bindFramebuffer(i.FRAMEBUFFER, a), i.framebufferTexture2D(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, r, 0), {
|
|
465
|
+
texture: r,
|
|
466
|
+
framebuffer: a
|
|
378
467
|
};
|
|
379
|
-
};
|
|
468
|
+
}, o = null;
|
|
469
|
+
if (n) {
|
|
470
|
+
let n = Math.min(4, i.getParameter(i.MAX_SAMPLES)), r = i.createFramebuffer();
|
|
471
|
+
i.bindFramebuffer(i.FRAMEBUFFER, r), o = {
|
|
472
|
+
framebuffer: r,
|
|
473
|
+
renderbuffers: [i.RGBA8, i.R8].map((r, a) => {
|
|
474
|
+
let o = i.createRenderbuffer();
|
|
475
|
+
return i.bindRenderbuffer(i.RENDERBUFFER, o), i.renderbufferStorageMultisample(i.RENDERBUFFER, n, r, e, t), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + a, i.RENDERBUFFER, o), o;
|
|
476
|
+
})
|
|
477
|
+
};
|
|
478
|
+
}
|
|
380
479
|
return this.#i = {
|
|
381
480
|
width: e,
|
|
382
481
|
height: t,
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
482
|
+
smooth: n,
|
|
483
|
+
mask: a(),
|
|
484
|
+
wide: a(),
|
|
485
|
+
coverage: n ? a(i.R8) : null,
|
|
486
|
+
msaa: o
|
|
487
|
+
}, i.bindFramebuffer(i.FRAMEBUFFER, null), this.#i;
|
|
386
488
|
}
|
|
387
489
|
#l(e) {
|
|
388
490
|
let t = this.gl, n = t.createTexture();
|
|
@@ -417,6 +519,6 @@ fragColor = vec4(linearToSrgb(ring.rgb), 1.0);
|
|
|
417
519
|
return r.activeTexture(r.TEXTURE15), r.bindTexture(r.TEXTURE_2D, i), r.texStorage2D(r.TEXTURE_2D, n, r.RGBA16F, e, t), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, r.REPEAT), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MIN_FILTER, r.LINEAR_MIPMAP_LINEAR), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MAG_FILTER, r.LINEAR), r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, !1), i;
|
|
418
520
|
}
|
|
419
521
|
};
|
|
420
|
-
export {
|
|
522
|
+
export { L as Passes };
|
|
421
523
|
|
|
422
524
|
//# sourceMappingURL=passes.js.map
|
package/dist/passes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passes.js","names":["mat4.invert","mat4.create","mat4.multiply","
|
|
1
|
+
{"version":3,"file":"passes.js","names":["mat4.invert","mat4.create","mat4.multiply","COMMON","uvMatrix","invert","TONE_MAP","multiply","FULLSCREEN_VERTEX","create","CLIP","MESH_VERTEX","SPOT_ATLAS_SIZE","EQUIRECT","CLIP_ONLY_FRAGMENT","POINT_SHADOW_SIZE","SHADOW_MAP_SIZE","irradianceSH","sh","sx","width","sy","height","dPhi","dTheta","y","theta","sinT","dy","weight","x","phi","dx","dz","basis","i","k","w","data","norm","band","out","c","BACKGROUND_FRAGMENT","PREFILTER_FRAGMENT","OUTLINE_MASK_FRAGMENT","OUTLINE_MAX","WIDEN","OUTLINE_WIDEN_FRAGMENT","OUTLINE_COMPOSITE_FRAGMENT","OUTLINE_COVER_FRAGMENT","SMOOTH","OUTLINE_SMOOTH_WIDEN_FRAGMENT","OUTLINE_SMOOTH_COMPOSITE_FRAGMENT","OUTLINE_MASK","OUTLINE_WIDEN","OUTLINE_COMPOSITE","OUTLINE_COVER","OUTLINE_SMOOTH_WIDEN","OUTLINE_SMOOTH_COMPOSITE","DEPTH","BACKGROUND","PREFILTER","ENV_WIDTH","ENV_LEVELS","Passes","gl","programs","resources","#environments","#shadow","#spotShadow","#pointShadow","#outline","texture","env","e","image","source","#floatTexture","prefiltered","program","framebuffer","level","hdr","blur","frame","tone","#depthTarget","#beginDepth","#drawDepth","shadow","#endDepth","toTexture","matrices","tiles","bias","half","spot","spots","toTile","#depthCube","point","face","item","casters","instances","defines","material","cutout","triplanar","viewProjection","map","targets","#outlineTargets","smooth","radius","outline","outlines","px","pixelRatio","attachment","target","widen","t","buffer","make","format","msaa","samples","size","framebuffers","levels"],"sources":["../src/irradiance.js"],"sourcesContent":["// Diffuse light from an environment image, for the renderer: computed once per environment.\n\n/** @import { DataImage } from './material/Texture.js' */\n\n/**\n * Diffuse light from an equirectangular environment, as nine spherical harmonic coefficients (RGB\n * each, flattened), scaled so the shader evaluates them with plain polynomial terms and gets\n * irradiance divided by PI - the light a white matte surface facing that way reflects.\n * @param {DataImage} image linear RGBA floats\n * @returns {Float32Array} 27 numbers\n */\nexport function irradianceSH({ data, width, height }) {\n const sh = new Float64Array(27)\n // sample a grid of at most 128 x 64 - plenty for the lowest frequencies\n const sx = Math.max(1, Math.floor(width / 128)), sy = Math.max(1, Math.floor(height / 64))\n const dPhi = (2 * Math.PI * sx) / width, dTheta = (Math.PI * sy) / height\n for (let y = 0; y < height; y += sy) {\n const theta = ((y + 0.5 * sy) / height) * Math.PI\n const sinT = Math.sin(theta), dy = Math.cos(theta)\n const weight = dPhi * dTheta * sinT\n for (let x = 0; x < width; x += sx) {\n const phi = ((x + 0.5 * sx) / width - 0.5) * 2 * Math.PI\n const dx = Math.cos(phi) * sinT, dz = Math.sin(phi) * sinT\n const basis = [1, dy, dz, dx, dx * dy, dy * dz, 3 * dz * dz - 1, dx * dz, dx * dx - dy * dy]\n const i = (y * width + x) * 4\n for (let k = 0; k < 9; k++) {\n const w = basis[k] * weight\n sh[k * 3] += data[i] * w\n sh[k * 3 + 1] += data[i + 1] * w\n sh[k * 3 + 2] += data[i + 2] * w\n }\n }\n }\n // projection uses the normalised basis Y = norm * polynomial, and evaluation multiplies by the\n // cosine lobe's band factors (PI, 2PI/3, PI/4) and norm again; then divide by PI\n const norm = [0.282095, 0.488603, 0.488603, 0.488603, 1.092548, 1.092548, 0.315392, 1.092548, 0.546274]\n const band = [1, 2 / 3, 2 / 3, 2 / 3, 1 / 4, 1 / 4, 1 / 4, 1 / 4, 1 / 4]\n const out = new Float32Array(27)\n for (let k = 0; k < 9; k++) {\n for (let c = 0; c < 3; c++) out[k * 3 + c] = sh[k * 3 + c] * norm[k] * norm[k] * band[k]\n }\n return out\n}\n"],"mappings":";;AAWA,SAAgBiB,EAAa,EAAE,SAAM,UAAO,aAAU;CACpD,IAAMC,oBAAK,IAAI,aAAa,EAAE,GAExBC,IAAK,KAAK,IAAI,GAAG,KAAK,MAAMC,IAAQ,GAAG,CAAC,GAAGC,IAAK,KAAK,IAAI,GAAG,KAAK,MAAMC,IAAS,EAAE,CAAC,GACnFC,IAAQ,IAAI,KAAK,KAAKJ,IAAMC,GAAOI,IAAU,KAAK,KAAKH,IAAMC;CACnE,KAAK,IAAIG,IAAI,GAAGA,IAAIH,GAAQ,KAAKD,GAAI;EACnC,IAAMK,KAAUD,IAAI,KAAMJ,KAAMC,IAAU,KAAK,IACzCK,IAAO,KAAK,IAAID,CAAK,GAAGE,IAAK,KAAK,IAAIF,CAAK,GAC3CG,IAASN,IAAOC,IAASG;EAC/B,KAAK,IAAIG,IAAI,GAAGA,IAAIV,GAAO,KAAKD,GAAI;GAClC,IAAMY,MAAQD,IAAI,KAAMX,KAAMC,IAAQ,MAAO,IAAI,KAAK,IAChDY,IAAK,KAAK,IAAID,CAAG,IAAIJ,GAAMM,IAAK,KAAK,IAAIF,CAAG,IAAIJ,GAChDO,IAAQ;IAAC;IAAGN;IAAIK;IAAID;IAAIA,IAAKJ;IAAIA,IAAKK;IAAI,IAAIA,IAAKA,IAAK;IAAGD,IAAKC;IAAID,IAAKA,IAAKJ,IAAKA;GAAE,GACrFO,KAAKV,IAAIL,IAAQU,KAAK;GAC5B,KAAK,IAAIM,IAAI,GAAGA,IAAI,GAAG,KAAK;IAC1B,IAAMC,IAAIH,EAAME,KAAKP;IAGrB,AAFA,EAAGO,IAAI,MAAME,EAAKH,KAAKE,GACvB,EAAGD,IAAI,IAAI,MAAME,EAAKH,IAAI,KAAKE,GAC/B,EAAGD,IAAI,IAAI,MAAME,EAAKH,IAAI,KAAKE;GACjC;EACF;CACF;CAGA,IAAME,IAAO;EAAC;EAAU;EAAU;EAAU;EAAU;EAAU;EAAU;EAAU;EAAU;CAAQ,GAChGC,IAAO;EAAC;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;CAAC,GACjEC,oBAAM,IAAI,aAAa,EAAE;CAC/B,KAAK,IAAIL,IAAI,GAAGA,IAAI,GAAG,KACrB,KAAK,IAAIM,IAAI,GAAGA,IAAI,GAAG,KAAK,EAAIN,IAAI,IAAIM,KAAKxB,EAAGkB,IAAI,IAAIM,KAAKH,EAAKH,KAAKG,EAAKH,KAAKI,EAAKJ;CAExF,OAAOK;AACT"}
|
package/dist/phoria2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { z as AmbientLight, xt as Box3, Q as CAMERA_PRESETS, et as Camera, gt as Clip, _t as Color, r as Curve, B as DirectionalLight, y as Drawable, st as Euler, K as Fog, R as Geometry, rt as Group, V as HemisphereLight, b as InstancedMesh, mt as LIGHT_LIMITS, x as Label, H as Light, S as Lines, St as Mat4, L as Material, C as Mesh, at as Node, ht as NullRenderer, pt as OrbitControl, tt as OrthographicCamera, nt as PerspectiveCamera, wt as PhoriaError, U as PointLight, w as Points, ot as Quat, X as Ray, Y as Raycaster, G as Scene, W as SpotLight, q as Texture, Ct as Vec3, T as View, E as WebGLRenderer, c as axes, l as box, $ as cameraPreset, t as create, i as curve, u as cylinder, d as edges, a as ellipse, f as extrude, o as fromPolygons, p as grid, m as icosphere, h as lathe, J as loadTexture, s as outline, g as plane, n as registerType, _ as sphere, v as torus } from "./core.js";
|
package/dist/picking.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as e, F as t, It as n, N as r, O as i, P as a, Pt as o } from "./core.js";
|
|
2
2
|
// src/webgl/picking.js
|
|
3
3
|
var s = 33, c = 4, l = `precision highp float;
|
|
4
4
|
precision highp int;
|
|
@@ -8,8 +8,8 @@ in vec3 vWorldPosition;
|
|
|
8
8
|
#endif
|
|
9
9
|
uniform uint uPickId;
|
|
10
10
|
layout(location = 0) out uvec4 pickOut;
|
|
11
|
-
${o}
|
|
12
11
|
${e}
|
|
12
|
+
${i}
|
|
13
13
|
void main() {
|
|
14
14
|
#ifdef CLIP
|
|
15
15
|
clipAway(vWorldPosition);
|
|
@@ -21,9 +21,9 @@ if (dot(p, p) > 1.0) discard;
|
|
|
21
21
|
pickOut = uvec4(uPickId, vPickElement, floatBitsToUint(gl_FragCoord.z), 1u);
|
|
22
22
|
}
|
|
23
23
|
`, u = {
|
|
24
|
-
mesh: [
|
|
25
|
-
points: [
|
|
26
|
-
lines: [
|
|
24
|
+
mesh: [a, l],
|
|
25
|
+
points: [t, l],
|
|
26
|
+
lines: [r, l]
|
|
27
27
|
}, d = class {
|
|
28
28
|
#e = null;
|
|
29
29
|
#t = /* @__PURE__ */ new Uint32Array(4356);
|
|
@@ -56,7 +56,7 @@ pickOut = uvec4(uPickId, vPickElement, floatBitsToUint(gl_FragCoord.z), 1u);
|
|
|
56
56
|
setTimeout(t, 0);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
#s(e,
|
|
59
|
+
#s(e, t, r, i, a, o) {
|
|
60
60
|
let c = this.gl, l = f(e);
|
|
61
61
|
if (!l.length) return null;
|
|
62
62
|
let u = this.#d();
|
|
@@ -66,7 +66,7 @@ pickOut = uvec4(uPickId, vPickElement, floatBitsToUint(gl_FragCoord.z), 1u);
|
|
|
66
66
|
0,
|
|
67
67
|
0
|
|
68
68
|
]), c.clearBufferfv(c.DEPTH, 0, [1]);
|
|
69
|
-
let d = s, p =
|
|
69
|
+
let d = s, p = t / i * 2 - 1, m = 1 - r / a * 2, h = new Float32Array([
|
|
70
70
|
i / d,
|
|
71
71
|
0,
|
|
72
72
|
0,
|
|
@@ -84,7 +84,7 @@ pickOut = uvec4(uPickId, vPickElement, floatBitsToUint(gl_FragCoord.z), 1u);
|
|
|
84
84
|
0,
|
|
85
85
|
1
|
|
86
86
|
]);
|
|
87
|
-
return
|
|
87
|
+
return n(this.#n, h, e.camera.projection), n(this.#r, this.#n, e.camera.view), l.forEach((t, n) => this.#u(t, n + 1, e, a, o)), c.bindVertexArray(null), {
|
|
88
88
|
items: l,
|
|
89
89
|
cx: p,
|
|
90
90
|
cy: m,
|
|
@@ -120,24 +120,19 @@ pickOut = uvec4(uPickId, vPickElement, floatBitsToUint(gl_FragCoord.z), 1u);
|
|
|
120
120
|
let e = this.gl;
|
|
121
121
|
return this.#a = e.createBuffer(), e.bindBuffer(e.PIXEL_PACK_BUFFER, this.#a), e.bufferData(e.PIXEL_PACK_BUFFER, this.#t.byteLength, e.STREAM_READ), e.bindBuffer(e.PIXEL_PACK_BUFFER, null), this.#a;
|
|
122
122
|
}
|
|
123
|
-
#u(e, t, n, r,
|
|
124
|
-
let
|
|
123
|
+
#u(e, t, n, r, i) {
|
|
124
|
+
let a = this.gl, { node: c, geometry: l, material: d, worldMatrix: f, instances: p } = e, m = c.drawMode, h = m === "points" ? "points" : m === "lines" ? "lines" : "mesh", g = ["PICK"];
|
|
125
125
|
p && g.push("INSTANCED"), h === "points" && (d.sizeAttenuation && g.push("SIZE_ATTENUATION"), d.map || g.push("ROUND")), h === "mesh" && e.clip && g.push("CLIP");
|
|
126
126
|
let _ = this.programs.ready(`pick-${h}`, g, u[h]);
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
1,
|
|
130
|
-
0,
|
|
131
|
-
0
|
|
132
|
-
]), e.clip && _.set("uClipPlane", e.clip.plane), h === "lines") {
|
|
133
|
-
o.disable(o.CULL_FACE), _.set("uResolution", [s, s]), _.set("uWidth", d.width * a), _.set("uNear", n.camera.near);
|
|
127
|
+
if (a.useProgram(_.program), _.set("uView", n.camera.view), _.set("uProjection", this.#n), _.set("uViewProjection", this.#r), _.set("uModel", f), _.set("uPickId", t), _.set("uHighlightIndex", -2), e.clip && _.set("uClipPlane", e.clip.plane), h === "lines") {
|
|
128
|
+
a.disable(a.CULL_FACE), _.set("uResolution", [s, s]), _.set("uWidth", d.width * i), _.set("uNear", n.camera.near);
|
|
134
129
|
let e = this.resources.lines(l);
|
|
135
|
-
|
|
130
|
+
a.bindVertexArray(e.vao), a.drawArraysInstanced(a.TRIANGLE_STRIP, 0, 4, Math.min(e.count, Math.floor(l.drawnCount / 2)));
|
|
136
131
|
} else if (h === "points") {
|
|
137
|
-
|
|
132
|
+
a.disable(a.CULL_FACE), _.set("uSize", d.sizeAttenuation ? d.size : d.size * i), _.set("uScale", n.camera.projection[5] * r / 2);
|
|
138
133
|
let e = this.resources.mesh(l, null, !1);
|
|
139
|
-
|
|
140
|
-
} else _.set("uNormalMatrix", this.#i), d.depthTest ?
|
|
134
|
+
a.bindVertexArray(e.vao), a.drawArrays(a.POINTS, 0, l.drawnVertices);
|
|
135
|
+
} else _.set("uNormalMatrix", this.#i), d.depthTest ? a.enable(a.DEPTH_TEST) : a.disable(a.DEPTH_TEST), d.doubleSided || e.clip?.cap ? a.disable(a.CULL_FACE) : (a.enable(a.CULL_FACE), a.cullFace(a.BACK), a.frontFace(o(f) < 0 ? a.CW : a.CCW)), this.resources.drawTriangles(l, p);
|
|
141
136
|
}
|
|
142
137
|
#d() {
|
|
143
138
|
if (this.#e) return this.#e;
|
package/dist/picking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picking.js","names":["mat4.determinant","
|
|
1
|
+
{"version":3,"file":"picking.js","names":["mat4.determinant","COMMON","POINTS_VERTEX","multiply","LINES_VERTEX","CLIP","MESH_VERTEX","determinant","REGION","TOLERANCE","PICK_FRAGMENT","SOURCES","Picker","gl","programs","resources","#target","#pack","#waiting","region","#drawRegion","frame","x","y","width","height","pixelRatio","#pixels","#decode","buffer","#readBuffer","fence","poll","resolve","items","pickable","target","#ensureTarget","s","cx","cy","zoom","#projection","#viewProjection","#draw","item","i","p","at","py","px","best","bestX","bestY","bestD","dy","dx","d","o","id","depth","ndc","mode","node","kind","defines","instances","material","program","worldMatrix","buffers","geometry","#normal","color","framebuffer","seen","ok","n","v"],"sources":[],"mappings":""}
|
package/dist/snapshot.js
CHANGED
package/dist/tooltip.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as e, Ot as t } from "./core.js";
|
|
2
2
|
// src/tooltip.js
|
|
3
3
|
var n = "\n:where(.phoria-tooltip) { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; max-width: 320px;\n padding: 6px 10px; border-radius: 6px; background: rgba(20, 20, 24, 0.92); color: #fff;\n font: 12px/1.45 system-ui, sans-serif; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); white-space: pre-line; }\n:where(.phoria-tooltip-title) { font-weight: 600; }\n:where(.phoria-tooltip-rows) { display: grid; grid-template-columns: auto auto; column-gap: 12px; }\n:where(.phoria-tooltip-rows > :nth-child(odd)) { opacity: 0.7; }\n:where(.phoria-tooltip-rows > :nth-child(even)) { text-align: right; font-variant-numeric: tabular-nums; }\n", r = 14, i = class {
|
|
4
4
|
el;
|
|
5
5
|
content;
|
|
6
6
|
constructor(r, i = "") {
|
|
7
|
-
if (typeof r != "function" &&
|
|
7
|
+
if (typeof r != "function" && e("View", `tooltip() takes a function (hit) => text, got ${t(r)}`), this.content = r, !document.getElementById("phoria-tooltip-style")) {
|
|
8
8
|
let e = document.createElement("style");
|
|
9
9
|
e.id = "phoria-tooltip-style", e.textContent = n, document.head.prepend(e);
|
|
10
10
|
}
|
|
@@ -48,7 +48,7 @@ function a(n) {
|
|
|
48
48
|
}
|
|
49
49
|
return e;
|
|
50
50
|
}
|
|
51
|
-
return
|
|
51
|
+
return e("View", `a tooltip function returns text, an element or { title, rows }, got ${t(n)}`);
|
|
52
52
|
}
|
|
53
53
|
export { i as Tooltip };
|
|
54
54
|
|