@tresjs/cientos 5.9.2 → 5.10.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/dist/index-Chqfwa4v.d.ts +6793 -0
- package/dist/trescientos.d.ts +348 -7057
- package/dist/trescientos.js +4451 -15280
- package/dist/useStars-DmGIezjm.js +11191 -0
- package/dist/webgpu.d.ts +252 -0
- package/dist/webgpu.js +1621 -0
- package/package.json +15 -3
package/dist/webgpu.js
ADDED
|
@@ -0,0 +1,1621 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* name: @tresjs/cientos
|
|
3
|
+
* version: v5.10.0
|
|
4
|
+
* (c) 2026
|
|
5
|
+
* description: Collection of useful helpers and fully functional, ready-made abstractions for Tres
|
|
6
|
+
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
|
+
*/
|
|
8
|
+
import { $ as useAnimations, $t as Decal_default, A as Icosahedron_default, At as OrbitControls_default, B as MarchingCubes_default, Bt as MERGED_INJECTION_KEY, C as Sphere_default, Ct as Stats, D as Ring_default, Dt as TransformControls_default, E as RoundedBox_default, Et as useHelper, F as Cone_default, Ft as Merged_default, G as htmlDefaults, Gt as useSurfaceSampler, H as useImage, Ht as ScreenSpace_default, I as Circle_default, It as Instances_default, J as useFBO, Jt as component_default$8, K as GradientTexture_default, Kt as useOutline, L as Box_default, Lt as Instance_default, M as gridDefaults, Mt as KeyboardControls_default, N as Dodecahedron_default, Nt as CameraControls_default, O as Plane_default, Ot as ScrollControls_default, P as Cylinder_default, Pt as BaseCameraControls, Q as useGLTFExporter, Qt as DecalDebugUI_default, R as Text3D_default, Rt as PositionMesh, S as Superformula_default, St as StatsGl, T as RoundedPlane_default, Tt as component_default$7, U as imageDefaults, Ut as ScreenSizer_default, V as MarchingCube_default, Vt as useMask, W as useHtml, Wt as component_default$10, X as component_default, Xt as Fit_default, Y as component_default$2, Yt as Levioso_default, Z as useIntersect, Zt as Edges_default, _ as Backdrop_default, _t as component_default$11, a as pick, an as CameraShake_default, at as glassDefaults, b as Torus_default, bt as component_default$9, c as sparklesDefaults, ct as useTextures, d as Smoke_default, dt as component_default$12, en as useDecalEditor, et as PositionalAudio_default, f as usePrecipitation, ft as useTexture, g as useEnvironment, gt as useFBX, h as component_default$3, ht as component_default$4, i as hasSetter, in as invalidateDecalGeometry, it as meshWobbleMaterialDefaults, j as useGrid, jt as MapControls_default, k as Octahedron_default, kt as PointerLockControls_default, l as toCooldownRatio, lt as useVideoTexture, m as lightformer_default, mt as useGLTF, n as starsDefaults, nn as getTextureAspect, nt as GlobalAudio, o as useSparkles, on as Billboard_default, ot as holographicDefaults, p as precipitationDefaults, pt as component_default$6, q as component_default$5, qt as outlineDefaults, r as extractBindingPosition, rn as getTextureName, rt as component_default$1, s as useEmptyDataTexture, sn as Align_default, st as toHolographicMaterialProps, t as useStars, tn as ensureTextureNames, tt as MouseParallax_default, u as toNoiseScale, ut as useProgress, v as Tube_default, vt as useSVG, w as ScreenQuad_default, wt as LOD_default, x as Tetrahedron_default, xt as useBVH, y as TorusKnot_default, yt as CircleShadow_default, z as MarchingPlane_default, zt as INSTANCES_INJECTION_KEY } from "./useStars-DmGIezjm.js";
|
|
9
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeDefaults, mergeProps, normalizeProps, onMounted, onUpdated, openBlock, renderSlot, shallowRef, unref, watch } from "vue";
|
|
10
|
+
import { extend, logWarning, useLoop, useTres, useTresContext } from "@tresjs/core";
|
|
11
|
+
import { InstancedBufferAttribute, Mesh, NormalBlending } from "three";
|
|
12
|
+
import { AdditiveBlending as AdditiveBlending$1, Color as Color$1, DataTexture as DataTexture$1, DoubleSide as DoubleSide$1, InstancedBufferAttribute as InstancedBufferAttribute$1, MathUtils as MathUtils$1, MeshBasicNodeMaterial, MeshPhysicalNodeMaterial, MeshStandardNodeMaterial, NodeMaterial, Object3D as Object3D$1, PointsNodeMaterial, Sprite, Vector2 as Vector2$1, Vector3 as Vector3$1 } from "three/webgpu";
|
|
13
|
+
import { Discard, Fn, If, abs, batch, cameraPosition, cameraProjectionMatrix, cameraViewMatrix, clamp, cos, diffuseColor, distance, dot, float, fract, fwidth, instancedBufferAttribute, instancedDynamicBufferAttribute, instancedMesh, length, materialReference, max, min, mix, modelViewMatrix, modelWorldMatrix, modelWorldMatrixInverse, morphReference, normalGeometry, normalLocal, normalize, positionGeometry, positionLocal, pow, sRGBTransferEOTF, saturate, screenDPR, select, sin, skinning, smoothstep, texture, time, uniform, uv, vec2, vec3, vec4 } from "three/tsl";
|
|
14
|
+
//#region src/core/abstractions/Outline/OutlineNodeMaterial.ts
|
|
15
|
+
var OutlineNodeMaterial = class extends MeshBasicNodeMaterial {
|
|
16
|
+
_outlineUniforms = {
|
|
17
|
+
thickness: uniform(outlineDefaults.thickness),
|
|
18
|
+
screenspace: uniform(Number(outlineDefaults.screenspace)),
|
|
19
|
+
size: uniform(new Vector2$1(1, 1))
|
|
20
|
+
};
|
|
21
|
+
_outlineVertexNode;
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.fog = false;
|
|
25
|
+
this.color.set(outlineDefaults.color);
|
|
26
|
+
this.opacity = outlineDefaults.opacity;
|
|
27
|
+
const u = this._outlineUniforms;
|
|
28
|
+
this._outlineVertexNode = Fn(() => {
|
|
29
|
+
const mvp = cameraProjectionMatrix.mul(modelViewMatrix);
|
|
30
|
+
const clipPosition = mvp.mul(vec4(positionLocal, 1)).toVar();
|
|
31
|
+
const clipNormal = mvp.mul(vec4(normalLocal, 0));
|
|
32
|
+
const offset = normalize(clipNormal.xy).mul(u.thickness).div(u.size).mul(clipPosition.w).mul(2);
|
|
33
|
+
const pixelOffset = vec4(clipPosition.xy.add(offset), clipPosition.zw);
|
|
34
|
+
return select(u.screenspace.greaterThan(.5), clipPosition, pixelOffset);
|
|
35
|
+
})();
|
|
36
|
+
this.vertexNode = this._outlineVertexNode;
|
|
37
|
+
}
|
|
38
|
+
setupPosition(builder) {
|
|
39
|
+
const { geometry } = builder;
|
|
40
|
+
const object = builder.object;
|
|
41
|
+
if (geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color) morphReference(object);
|
|
42
|
+
if (object.isSkinnedMesh) skinning(object);
|
|
43
|
+
positionLocal.addAssign(normalLocal.mul(this._outlineUniforms.thickness).mul(this._outlineUniforms.screenspace));
|
|
44
|
+
if (object.isBatchedMesh) batch(object);
|
|
45
|
+
if (object.isInstancedMesh && object.instanceMatrix?.isInstancedBufferAttribute) instancedMesh(object);
|
|
46
|
+
return positionLocal;
|
|
47
|
+
}
|
|
48
|
+
copy(source) {
|
|
49
|
+
super.copy(source);
|
|
50
|
+
this.vertexNode = this._outlineVertexNode;
|
|
51
|
+
this.size.copy(source.size);
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
get thickness() {
|
|
55
|
+
return this._outlineUniforms.thickness.value;
|
|
56
|
+
}
|
|
57
|
+
set thickness(value) {
|
|
58
|
+
this._outlineUniforms.thickness.value = value;
|
|
59
|
+
}
|
|
60
|
+
get screenspace() {
|
|
61
|
+
return this._outlineUniforms.screenspace.value === 1;
|
|
62
|
+
}
|
|
63
|
+
set screenspace(value) {
|
|
64
|
+
this._outlineUniforms.screenspace.value = value ? 1 : 0;
|
|
65
|
+
}
|
|
66
|
+
get size() {
|
|
67
|
+
return this._outlineUniforms.size.value;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/core/abstractions/Outline/webgpu.vue
|
|
72
|
+
var webgpu_default$7 = /* @__PURE__ */ defineComponent({
|
|
73
|
+
__name: "webgpu",
|
|
74
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
75
|
+
color: {
|
|
76
|
+
type: null,
|
|
77
|
+
required: false
|
|
78
|
+
},
|
|
79
|
+
screenspace: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
required: false
|
|
82
|
+
},
|
|
83
|
+
opacity: {
|
|
84
|
+
type: Number,
|
|
85
|
+
required: false
|
|
86
|
+
},
|
|
87
|
+
transparent: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
required: false
|
|
90
|
+
},
|
|
91
|
+
thickness: {
|
|
92
|
+
type: Number,
|
|
93
|
+
required: false
|
|
94
|
+
},
|
|
95
|
+
angle: {
|
|
96
|
+
type: Number,
|
|
97
|
+
required: false
|
|
98
|
+
},
|
|
99
|
+
toneMapped: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
required: false
|
|
102
|
+
},
|
|
103
|
+
polygonOffset: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
required: false
|
|
106
|
+
},
|
|
107
|
+
polygonOffsetFactor: {
|
|
108
|
+
type: Number,
|
|
109
|
+
required: false
|
|
110
|
+
},
|
|
111
|
+
renderOrder: {
|
|
112
|
+
type: Number,
|
|
113
|
+
required: false
|
|
114
|
+
}
|
|
115
|
+
}, outlineDefaults),
|
|
116
|
+
setup(__props, { expose: __expose }) {
|
|
117
|
+
const props = __props;
|
|
118
|
+
const groupRef = shallowRef();
|
|
119
|
+
__expose({ instance: groupRef });
|
|
120
|
+
useOutline(props, groupRef, new OutlineNodeMaterial());
|
|
121
|
+
return (_ctx, _cache) => {
|
|
122
|
+
return openBlock(), createElementBlock("TresGroup", {
|
|
123
|
+
ref_key: "groupRef",
|
|
124
|
+
ref: groupRef
|
|
125
|
+
}, null, 512);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/core/materials/holographicMaterial/HolographicNodeMaterial.ts
|
|
131
|
+
/**
|
|
132
|
+
* TSL port of the holographic material by Anderson Mancini. See `material.ts` for the license.
|
|
133
|
+
* `HolographicMaterial.ts` has the GLSL version. A fix here must go there too.
|
|
134
|
+
*/
|
|
135
|
+
var HolographicNodeMaterial = class extends MeshBasicNodeMaterial {
|
|
136
|
+
holographicUniforms = {
|
|
137
|
+
fresnelAmount: uniform(holographicDefaults.fresnelAmount),
|
|
138
|
+
fresnelOpacity: uniform(holographicDefaults.fresnelOpacity),
|
|
139
|
+
scanlineSize: uniform(holographicDefaults.scanlineSize),
|
|
140
|
+
hologramBrightness: uniform(holographicDefaults.hologramBrightness),
|
|
141
|
+
signalSpeed: uniform(holographicDefaults.signalSpeed),
|
|
142
|
+
hologramOpacity: uniform(holographicDefaults.hologramOpacity),
|
|
143
|
+
hologramColor: uniform(new Color$1(holographicDefaults.hologramColor)),
|
|
144
|
+
enableBlinking: uniform(Number(holographicDefaults.enableBlinking)),
|
|
145
|
+
blinkFresnelOnly: uniform(Number(holographicDefaults.blinkFresnelOnly))
|
|
146
|
+
};
|
|
147
|
+
constructor() {
|
|
148
|
+
super();
|
|
149
|
+
this.transparent = true;
|
|
150
|
+
this.blending = AdditiveBlending$1;
|
|
151
|
+
this.depthTest = false;
|
|
152
|
+
this.fog = false;
|
|
153
|
+
const u = this.holographicUniforms;
|
|
154
|
+
const clipPosition = cameraProjectionMatrix.mul(modelViewMatrix).mul(vec4(positionLocal, 1)).toVarying();
|
|
155
|
+
const positionW = vec4(positionLocal, 1).mul(modelWorldMatrix).xyz.toVarying();
|
|
156
|
+
const normalW = normalize(vec4(normalGeometry, 0).mul(modelWorldMatrix).xyz).toVarying();
|
|
157
|
+
const flicker = (amount, t) => clamp(fract(cos(t).mul(43758.5453123)), amount, 1);
|
|
158
|
+
const random = (a, b) => fract(cos(dot(vec2(a, b), vec2(12.9898, 78.233))).mul(43758.5453));
|
|
159
|
+
const smoothstepAnyOrder = (edge0, edge1, x) => {
|
|
160
|
+
const t = saturate(x.sub(edge0).div(edge1.sub(edge0)));
|
|
161
|
+
return t.mul(t).mul(float(3).sub(t.mul(2)));
|
|
162
|
+
};
|
|
163
|
+
this.colorNode = Fn(() => {
|
|
164
|
+
const vUv = uv();
|
|
165
|
+
const myUV = fract(clipPosition.xy.div(clipPosition.w).mul(.5).add(.5));
|
|
166
|
+
const signalTime = time.mul(u.signalSpeed);
|
|
167
|
+
const scanlines = float(10).toVar();
|
|
168
|
+
scanlines.addAssign(sin(signalTime.mul(20.8).sub(myUV.y.mul(60).mul(u.scanlineSize))).mul(20));
|
|
169
|
+
scanlines.mulAssign(smoothstepAnyOrder(cos(signalTime.add(myUV.y.mul(u.scanlineSize))).mul(1.3), float(.78), float(.9)));
|
|
170
|
+
scanlines.mulAssign(max(.25, sin(signalTime)));
|
|
171
|
+
const r = random(vUv.x, vUv.y);
|
|
172
|
+
const b = random(vUv.y.mul(.9), vUv.y.mul(.2));
|
|
173
|
+
const hologramColor = vec4(u.hologramColor, mix(u.hologramBrightness, vUv.y, .5)).add(vec4(r.mul(scanlines), b.mul(scanlines), r, 1).div(84)).toVar();
|
|
174
|
+
const scanlineMix = mix(vec4(0), hologramColor, hologramColor.a);
|
|
175
|
+
const viewDirectionW = normalize(cameraPosition.sub(positionW));
|
|
176
|
+
const fresnelFacing = dot(viewDirectionW, normalW).mul(float(1.6).sub(u.fresnelOpacity.div(2)));
|
|
177
|
+
const fresnelEffect = clamp(u.fresnelAmount.sub(fresnelFacing), 0, u.fresnelOpacity);
|
|
178
|
+
const blinkValue = mix(float(1), float(.6).sub(u.signalSpeed), u.enableBlinking);
|
|
179
|
+
const blink = flicker(blinkValue, signalTime.mul(.02));
|
|
180
|
+
const finalColor = mix(scanlineMix.rgb.mul(blink).add(fresnelEffect), scanlineMix.rgb.add(fresnelEffect.mul(blink)), u.blinkFresnelOnly);
|
|
181
|
+
return vec4(sRGBTransferEOTF(saturate(finalColor)), u.hologramOpacity);
|
|
182
|
+
})();
|
|
183
|
+
}
|
|
184
|
+
copy(source) {
|
|
185
|
+
const { holographicUniforms, colorNode } = this;
|
|
186
|
+
super.copy(source);
|
|
187
|
+
Object.assign(this, {
|
|
188
|
+
holographicUniforms,
|
|
189
|
+
colorNode
|
|
190
|
+
});
|
|
191
|
+
for (const key of Object.keys(holographicUniforms)) {
|
|
192
|
+
const value = source.holographicUniforms[key].value;
|
|
193
|
+
const uniform = holographicUniforms[key];
|
|
194
|
+
if (value instanceof Color$1) uniform.value.copy(value);
|
|
195
|
+
else uniform.value = value;
|
|
196
|
+
}
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
get fresnelAmount() {
|
|
200
|
+
return this.holographicUniforms.fresnelAmount.value;
|
|
201
|
+
}
|
|
202
|
+
set fresnelAmount(value) {
|
|
203
|
+
this.holographicUniforms.fresnelAmount.value = value;
|
|
204
|
+
}
|
|
205
|
+
get fresnelOpacity() {
|
|
206
|
+
return this.holographicUniforms.fresnelOpacity.value;
|
|
207
|
+
}
|
|
208
|
+
set fresnelOpacity(value) {
|
|
209
|
+
this.holographicUniforms.fresnelOpacity.value = value;
|
|
210
|
+
}
|
|
211
|
+
get scanlineSize() {
|
|
212
|
+
return this.holographicUniforms.scanlineSize.value;
|
|
213
|
+
}
|
|
214
|
+
set scanlineSize(value) {
|
|
215
|
+
this.holographicUniforms.scanlineSize.value = value;
|
|
216
|
+
}
|
|
217
|
+
get hologramBrightness() {
|
|
218
|
+
return this.holographicUniforms.hologramBrightness.value;
|
|
219
|
+
}
|
|
220
|
+
set hologramBrightness(value) {
|
|
221
|
+
this.holographicUniforms.hologramBrightness.value = value;
|
|
222
|
+
}
|
|
223
|
+
get signalSpeed() {
|
|
224
|
+
return this.holographicUniforms.signalSpeed.value;
|
|
225
|
+
}
|
|
226
|
+
set signalSpeed(value) {
|
|
227
|
+
this.holographicUniforms.signalSpeed.value = value;
|
|
228
|
+
}
|
|
229
|
+
get hologramOpacity() {
|
|
230
|
+
return this.holographicUniforms.hologramOpacity.value;
|
|
231
|
+
}
|
|
232
|
+
set hologramOpacity(value) {
|
|
233
|
+
this.holographicUniforms.hologramOpacity.value = value;
|
|
234
|
+
}
|
|
235
|
+
get hologramColor() {
|
|
236
|
+
return this.holographicUniforms.hologramColor.value;
|
|
237
|
+
}
|
|
238
|
+
get enableBlinking() {
|
|
239
|
+
return this.holographicUniforms.enableBlinking.value === 1;
|
|
240
|
+
}
|
|
241
|
+
set enableBlinking(value) {
|
|
242
|
+
this.holographicUniforms.enableBlinking.value = value ? 1 : 0;
|
|
243
|
+
}
|
|
244
|
+
get blinkFresnelOnly() {
|
|
245
|
+
return this.holographicUniforms.blinkFresnelOnly.value === 1;
|
|
246
|
+
}
|
|
247
|
+
set blinkFresnelOnly(value) {
|
|
248
|
+
this.holographicUniforms.blinkFresnelOnly.value = value ? 1 : 0;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/core/materials/holographicMaterial/webgpu.vue
|
|
253
|
+
var webgpu_default$1 = /* @__PURE__ */ defineComponent({
|
|
254
|
+
__name: "webgpu",
|
|
255
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
256
|
+
fresnelAmount: {
|
|
257
|
+
type: Number,
|
|
258
|
+
required: false
|
|
259
|
+
},
|
|
260
|
+
fresnelOpacity: {
|
|
261
|
+
type: Number,
|
|
262
|
+
required: false
|
|
263
|
+
},
|
|
264
|
+
blinkFresnelOnly: {
|
|
265
|
+
type: Boolean,
|
|
266
|
+
required: false
|
|
267
|
+
},
|
|
268
|
+
enableBlinking: {
|
|
269
|
+
type: Boolean,
|
|
270
|
+
required: false
|
|
271
|
+
},
|
|
272
|
+
enableAdditive: {
|
|
273
|
+
type: Boolean,
|
|
274
|
+
required: false
|
|
275
|
+
},
|
|
276
|
+
hologramBrightness: {
|
|
277
|
+
type: Number,
|
|
278
|
+
required: false
|
|
279
|
+
},
|
|
280
|
+
scanlineSize: {
|
|
281
|
+
type: Number,
|
|
282
|
+
required: false
|
|
283
|
+
},
|
|
284
|
+
signalSpeed: {
|
|
285
|
+
type: Number,
|
|
286
|
+
required: false
|
|
287
|
+
},
|
|
288
|
+
hologramOpacity: {
|
|
289
|
+
type: Number,
|
|
290
|
+
required: false
|
|
291
|
+
},
|
|
292
|
+
hologramColor: {
|
|
293
|
+
type: null,
|
|
294
|
+
required: false
|
|
295
|
+
},
|
|
296
|
+
side: {
|
|
297
|
+
type: null,
|
|
298
|
+
required: false
|
|
299
|
+
}
|
|
300
|
+
}, holographicDefaults),
|
|
301
|
+
setup(__props, { expose: __expose }) {
|
|
302
|
+
const props = __props;
|
|
303
|
+
extend({ HolographicNodeMaterial });
|
|
304
|
+
const materialRef = shallowRef();
|
|
305
|
+
__expose({
|
|
306
|
+
root: materialRef,
|
|
307
|
+
constructor: HolographicNodeMaterial
|
|
308
|
+
});
|
|
309
|
+
const materialProps = computed(() => toHolographicMaterialProps(props));
|
|
310
|
+
return (_ctx, _cache) => {
|
|
311
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" The TSL `time` node animates the material, so it needs no per-frame update. "), createElementVNode("TresHolographicNodeMaterial", mergeProps({
|
|
312
|
+
ref_key: "materialRef",
|
|
313
|
+
ref: materialRef
|
|
314
|
+
}, materialProps.value), null, 16)], 2112);
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/core/materials/meshDiscardMaterial/MeshDiscardNodeMaterial.ts
|
|
320
|
+
var MeshDiscardNodeMaterial = class extends NodeMaterial {
|
|
321
|
+
constructor() {
|
|
322
|
+
super();
|
|
323
|
+
this.fog = false;
|
|
324
|
+
this.vertexNode = vec4(0);
|
|
325
|
+
this.fragmentNode = Fn(() => {
|
|
326
|
+
Discard();
|
|
327
|
+
return vec4(0);
|
|
328
|
+
})();
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/core/materials/meshDiscardMaterial/webgpu.vue
|
|
333
|
+
var webgpu_default$4 = /* @__PURE__ */ defineComponent({
|
|
334
|
+
__name: "webgpu",
|
|
335
|
+
setup(__props, { expose: __expose }) {
|
|
336
|
+
const meshDiscardMaterialRef = shallowRef();
|
|
337
|
+
const { extend } = useTresContext();
|
|
338
|
+
extend({ MeshDiscardNodeMaterial });
|
|
339
|
+
__expose({ instance: meshDiscardMaterialRef });
|
|
340
|
+
return (_ctx, _cache) => {
|
|
341
|
+
return openBlock(), createElementBlock("TresMeshDiscardNodeMaterial", {
|
|
342
|
+
ref_key: "meshDiscardMaterialRef",
|
|
343
|
+
ref: meshDiscardMaterialRef
|
|
344
|
+
}, null, 512);
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/core/materials/meshGlassMaterial/MeshGlassNodeMaterial.ts
|
|
350
|
+
/**
|
|
351
|
+
* Node material version of `MeshGlassMaterial`.
|
|
352
|
+
*
|
|
353
|
+
* The GLSL version fakes `isMeshPhysicalMaterial` on a `MeshStandardMaterial`. `WebGPURenderer`
|
|
354
|
+
* picks the node material from `material.type`, so it renders that one as a standard material
|
|
355
|
+
* without transmission. `MeshPhysicalNodeMaterial` does transmission and clearcoat itself, so this
|
|
356
|
+
* port only needs the glass start values.
|
|
357
|
+
*/
|
|
358
|
+
var MeshGlassNodeMaterial = class extends MeshPhysicalNodeMaterial {
|
|
359
|
+
constructor(parameters = {}) {
|
|
360
|
+
super();
|
|
361
|
+
this.setValues({
|
|
362
|
+
...glassDefaults,
|
|
363
|
+
...parameters
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
get reflectivity() {
|
|
367
|
+
return MathUtils$1.clamp(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1);
|
|
368
|
+
}
|
|
369
|
+
set reflectivity(reflectivity) {
|
|
370
|
+
this.ior = (1 + .4 * reflectivity) / (1 - .4 * reflectivity);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/core/materials/meshGlassMaterial/webgpu.vue
|
|
375
|
+
var webgpu_default$5 = /* @__PURE__ */ defineComponent({
|
|
376
|
+
__name: "webgpu",
|
|
377
|
+
setup(__props, { expose: __expose }) {
|
|
378
|
+
const materialRef = shallowRef();
|
|
379
|
+
extend({ MeshGlassNodeMaterial });
|
|
380
|
+
__expose({ instance: materialRef });
|
|
381
|
+
return (_ctx, _cache) => {
|
|
382
|
+
return openBlock(), createElementBlock("TresMeshGlassNodeMaterial", {
|
|
383
|
+
ref_key: "materialRef",
|
|
384
|
+
ref: materialRef
|
|
385
|
+
}, null, 512);
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/core/materials/meshWobbleMaterial/MeshWobbleNodeMaterial.ts
|
|
391
|
+
var MeshWobbleNodeMaterial = class extends MeshStandardNodeMaterial {
|
|
392
|
+
_wobbleUniforms = {
|
|
393
|
+
time: uniform(0),
|
|
394
|
+
factor: uniform(meshWobbleMaterialDefaults.factor)
|
|
395
|
+
};
|
|
396
|
+
_wobbleNode;
|
|
397
|
+
constructor(parameters) {
|
|
398
|
+
super();
|
|
399
|
+
const u = this._wobbleUniforms;
|
|
400
|
+
this._wobbleNode = Fn(() => {
|
|
401
|
+
const theta = sin(u.time.add(positionLocal.y)).div(2).mul(u.factor);
|
|
402
|
+
const c = cos(theta).toVar();
|
|
403
|
+
const s = sin(theta).toVar();
|
|
404
|
+
const rotate = (v) => vec3(c.mul(v.x).add(s.mul(v.z)), v.y, c.mul(v.z).sub(s.mul(v.x)));
|
|
405
|
+
normalLocal.assign(rotate(normalLocal));
|
|
406
|
+
return rotate(positionLocal);
|
|
407
|
+
})();
|
|
408
|
+
this.castShadowPositionNode = this._wobbleNode;
|
|
409
|
+
this.setValues(parameters);
|
|
410
|
+
}
|
|
411
|
+
setupPosition(builder) {
|
|
412
|
+
positionLocal.assign(this._wobbleNode);
|
|
413
|
+
return super.setupPosition(builder);
|
|
414
|
+
}
|
|
415
|
+
copy(source) {
|
|
416
|
+
super.copy(source);
|
|
417
|
+
this.castShadowPositionNode = this._wobbleNode;
|
|
418
|
+
return this;
|
|
419
|
+
}
|
|
420
|
+
get time() {
|
|
421
|
+
return this._wobbleUniforms.time.value;
|
|
422
|
+
}
|
|
423
|
+
set time(value) {
|
|
424
|
+
this._wobbleUniforms.time.value = value;
|
|
425
|
+
}
|
|
426
|
+
get factor() {
|
|
427
|
+
return this._wobbleUniforms.factor.value;
|
|
428
|
+
}
|
|
429
|
+
set factor(value) {
|
|
430
|
+
this._wobbleUniforms.factor.value = value;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/core/materials/meshWobbleMaterial/webgpu.vue?vue&type=script&setup=true&lang.ts
|
|
435
|
+
const _hoisted_1$7 = ["factor"];
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/core/materials/meshWobbleMaterial/webgpu.vue
|
|
438
|
+
var webgpu_default$6 = /* @__PURE__ */ defineComponent({
|
|
439
|
+
__name: "webgpu",
|
|
440
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
441
|
+
speed: {
|
|
442
|
+
type: Number,
|
|
443
|
+
required: false
|
|
444
|
+
},
|
|
445
|
+
factor: {
|
|
446
|
+
type: Number,
|
|
447
|
+
required: false
|
|
448
|
+
}
|
|
449
|
+
}, meshWobbleMaterialDefaults),
|
|
450
|
+
setup(__props, { expose: __expose }) {
|
|
451
|
+
const props = __props;
|
|
452
|
+
const materialRef = shallowRef();
|
|
453
|
+
const { extend, invalidate } = useTres();
|
|
454
|
+
extend({ MeshWobbleNodeMaterial });
|
|
455
|
+
watch(props, () => {
|
|
456
|
+
invalidate();
|
|
457
|
+
});
|
|
458
|
+
const { onBeforeRender } = useLoop();
|
|
459
|
+
onBeforeRender(({ elapsed }) => {
|
|
460
|
+
if (materialRef.value) {
|
|
461
|
+
materialRef.value.time = elapsed * props.speed;
|
|
462
|
+
invalidate();
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
__expose({ instance: materialRef });
|
|
466
|
+
return (_ctx, _cache) => {
|
|
467
|
+
return openBlock(), createElementBlock("TresMeshWobbleNodeMaterial", {
|
|
468
|
+
ref_key: "materialRef",
|
|
469
|
+
ref: materialRef,
|
|
470
|
+
factor: __props.factor
|
|
471
|
+
}, null, 8, _hoisted_1$7);
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/core/materials/pointMaterial/PointNodeMaterial.ts
|
|
477
|
+
let warnedPoints = false;
|
|
478
|
+
var PointNodeMaterial = class extends PointsNodeMaterial {
|
|
479
|
+
constructor(parameters) {
|
|
480
|
+
super();
|
|
481
|
+
this.alphaToCoverage = false;
|
|
482
|
+
this.setValues(parameters);
|
|
483
|
+
}
|
|
484
|
+
setupDiffuseColor(builder) {
|
|
485
|
+
super.setupDiffuseColor(builder);
|
|
486
|
+
if (builder.object.isPoints) {
|
|
487
|
+
if (!warnedPoints) {
|
|
488
|
+
warnedPoints = true;
|
|
489
|
+
logWarning("<PointMaterial> on <TresPoints> draws 1 pixel points under WebGPU. Put it on a <TresSprite> with `count` and a `positionNode` instead.");
|
|
490
|
+
}
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (!this.transparent && this.blending === NormalBlending && !this.alphaToCoverage) return;
|
|
494
|
+
const cxy = uv().mul(2).sub(1);
|
|
495
|
+
const r = dot(cxy, cxy);
|
|
496
|
+
const delta = fwidth(r);
|
|
497
|
+
const mask = float(1).sub(smoothstep(float(1).sub(delta), float(1).add(delta), r));
|
|
498
|
+
diffuseColor.a.assign(diffuseColor.a.mul(mask));
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
//#endregion
|
|
502
|
+
//#region src/core/materials/pointMaterial/webgpu.vue?vue&type=script&setup=true&lang.ts
|
|
503
|
+
const _hoisted_1$6 = ["size-attenuation"];
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/core/materials/pointMaterial/webgpu.vue
|
|
506
|
+
var webgpu_default$8 = /* @__PURE__ */ defineComponent({
|
|
507
|
+
__name: "webgpu",
|
|
508
|
+
props: { sizeAttenuation: {
|
|
509
|
+
type: Boolean,
|
|
510
|
+
required: false
|
|
511
|
+
} },
|
|
512
|
+
setup(__props, { expose: __expose }) {
|
|
513
|
+
extend({ PointNodeMaterial });
|
|
514
|
+
const materialRef = shallowRef();
|
|
515
|
+
const shaderKey = (m) => [
|
|
516
|
+
m.sizeAttenuation,
|
|
517
|
+
m.transparent,
|
|
518
|
+
m.blending,
|
|
519
|
+
m.alphaToCoverage,
|
|
520
|
+
m.vertexColors,
|
|
521
|
+
!!m.map,
|
|
522
|
+
!!m.alphaMap,
|
|
523
|
+
m.alphaTest > 0
|
|
524
|
+
].join();
|
|
525
|
+
let lastKey = "";
|
|
526
|
+
onMounted(() => {
|
|
527
|
+
if (materialRef.value) lastKey = shaderKey(materialRef.value);
|
|
528
|
+
});
|
|
529
|
+
onUpdated(() => {
|
|
530
|
+
const material = materialRef.value;
|
|
531
|
+
if (!material) return;
|
|
532
|
+
const key = shaderKey(material);
|
|
533
|
+
if (key !== lastKey) material.needsUpdate = true;
|
|
534
|
+
lastKey = key;
|
|
535
|
+
});
|
|
536
|
+
__expose({ instance: materialRef });
|
|
537
|
+
return (_ctx, _cache) => {
|
|
538
|
+
return openBlock(), createElementBlock("TresPointNodeMaterial", {
|
|
539
|
+
ref_key: "materialRef",
|
|
540
|
+
ref: materialRef,
|
|
541
|
+
"size-attenuation": __props.sizeAttenuation
|
|
542
|
+
}, null, 8, _hoisted_1$6);
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/core/objects/Html/HtmlNodeMaterial.ts
|
|
548
|
+
var HtmlNodeMaterial = class extends NodeMaterial {
|
|
549
|
+
_htmlUniforms = {
|
|
550
|
+
uWidth: uniform(1),
|
|
551
|
+
uHeight: uniform(1)
|
|
552
|
+
};
|
|
553
|
+
constructor(billboard) {
|
|
554
|
+
super();
|
|
555
|
+
this.side = DoubleSide$1;
|
|
556
|
+
this.fog = false;
|
|
557
|
+
if (billboard) {
|
|
558
|
+
const u = this._htmlUniforms;
|
|
559
|
+
const center = modelViewMatrix.mul(vec4(0, 0, 0, 1));
|
|
560
|
+
const corner = vec4(positionGeometry.xy.mul(vec2(u.uWidth, u.uHeight)), 0, 0);
|
|
561
|
+
this.vertexNode = cameraProjectionMatrix.mul(center.add(corner));
|
|
562
|
+
}
|
|
563
|
+
this.fragmentNode = vec4(0, 0, 0, 0);
|
|
564
|
+
}
|
|
565
|
+
get uWidth() {
|
|
566
|
+
return this._htmlUniforms.uWidth.value;
|
|
567
|
+
}
|
|
568
|
+
set uWidth(value) {
|
|
569
|
+
this._htmlUniforms.uWidth.value = value;
|
|
570
|
+
}
|
|
571
|
+
get uHeight() {
|
|
572
|
+
return this._htmlUniforms.uHeight.value;
|
|
573
|
+
}
|
|
574
|
+
set uHeight(value) {
|
|
575
|
+
this._htmlUniforms.uHeight.value = value;
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
//#endregion
|
|
579
|
+
//#region src/core/objects/Html/webgpu.vue?vue&type=script&setup=true&lang.ts
|
|
580
|
+
const _hoisted_1$5 = [
|
|
581
|
+
"material",
|
|
582
|
+
"cast-shadow",
|
|
583
|
+
"receive-shadow",
|
|
584
|
+
"geometry"
|
|
585
|
+
];
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region src/core/objects/Html/webgpu.vue
|
|
588
|
+
var webgpu_default$2 = /* @__PURE__ */ defineComponent({
|
|
589
|
+
__name: "webgpu",
|
|
590
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
591
|
+
geometry: {
|
|
592
|
+
type: null,
|
|
593
|
+
required: false
|
|
594
|
+
},
|
|
595
|
+
material: {
|
|
596
|
+
type: null,
|
|
597
|
+
required: false
|
|
598
|
+
},
|
|
599
|
+
as: {
|
|
600
|
+
type: String,
|
|
601
|
+
required: false
|
|
602
|
+
},
|
|
603
|
+
transform: {
|
|
604
|
+
type: Boolean,
|
|
605
|
+
required: false
|
|
606
|
+
},
|
|
607
|
+
prepend: {
|
|
608
|
+
type: Boolean,
|
|
609
|
+
required: false
|
|
610
|
+
},
|
|
611
|
+
portal: {
|
|
612
|
+
type: null,
|
|
613
|
+
required: false
|
|
614
|
+
},
|
|
615
|
+
wrapperClass: {
|
|
616
|
+
type: String,
|
|
617
|
+
required: false
|
|
618
|
+
},
|
|
619
|
+
eps: {
|
|
620
|
+
type: Number,
|
|
621
|
+
required: false
|
|
622
|
+
},
|
|
623
|
+
distanceFactor: {
|
|
624
|
+
type: Number,
|
|
625
|
+
required: false
|
|
626
|
+
},
|
|
627
|
+
fullscreen: {
|
|
628
|
+
type: Boolean,
|
|
629
|
+
required: false
|
|
630
|
+
},
|
|
631
|
+
center: {
|
|
632
|
+
type: Boolean,
|
|
633
|
+
required: false
|
|
634
|
+
},
|
|
635
|
+
pointerEvents: {
|
|
636
|
+
type: String,
|
|
637
|
+
required: false
|
|
638
|
+
},
|
|
639
|
+
sprite: {
|
|
640
|
+
type: Boolean,
|
|
641
|
+
required: false
|
|
642
|
+
},
|
|
643
|
+
transparentMaterial: {
|
|
644
|
+
type: Boolean,
|
|
645
|
+
required: false
|
|
646
|
+
},
|
|
647
|
+
zIndexRange: {
|
|
648
|
+
type: Array,
|
|
649
|
+
required: false
|
|
650
|
+
},
|
|
651
|
+
calculatePosition: {
|
|
652
|
+
type: null,
|
|
653
|
+
required: false
|
|
654
|
+
},
|
|
655
|
+
occlude: {
|
|
656
|
+
type: [
|
|
657
|
+
Object,
|
|
658
|
+
null,
|
|
659
|
+
Array,
|
|
660
|
+
Boolean,
|
|
661
|
+
String
|
|
662
|
+
],
|
|
663
|
+
required: false
|
|
664
|
+
},
|
|
665
|
+
castShadow: {
|
|
666
|
+
type: Boolean,
|
|
667
|
+
required: false
|
|
668
|
+
},
|
|
669
|
+
receiveShadow: {
|
|
670
|
+
type: Boolean,
|
|
671
|
+
required: false
|
|
672
|
+
}
|
|
673
|
+
}, htmlDefaults),
|
|
674
|
+
emits: ["onOcclude"],
|
|
675
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
676
|
+
const { groupRef, occlusionMeshRef, defaultPlaneGeometry, effectiveMaterial, isRayCastOcclusion, isVisible } = useHtml(__props, __emit, (billboard) => new HtmlNodeMaterial(billboard));
|
|
677
|
+
__expose({
|
|
678
|
+
instance: groupRef,
|
|
679
|
+
isVisible,
|
|
680
|
+
occlusionMesh: occlusionMeshRef
|
|
681
|
+
});
|
|
682
|
+
return (_ctx, _cache) => {
|
|
683
|
+
return openBlock(), createElementBlock("TresGroup", {
|
|
684
|
+
ref_key: "groupRef",
|
|
685
|
+
ref: groupRef
|
|
686
|
+
}, [__props.occlude && !unref(isRayCastOcclusion) ? (openBlock(), createElementBlock("TresMesh", {
|
|
687
|
+
key: 0,
|
|
688
|
+
ref_key: "occlusionMeshRef",
|
|
689
|
+
ref: occlusionMeshRef,
|
|
690
|
+
material: unref(effectiveMaterial),
|
|
691
|
+
"cast-shadow": __props.castShadow,
|
|
692
|
+
"receive-shadow": __props.receiveShadow,
|
|
693
|
+
geometry: __props.geometry || unref(defaultPlaneGeometry)
|
|
694
|
+
}, null, 8, _hoisted_1$5)) : createCommentVNode("v-if", true)], 512);
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
//#endregion
|
|
699
|
+
//#region src/core/objects/Image/ImageNodeMaterial.ts
|
|
700
|
+
const emptyTexture = /* @__PURE__ */ (() => {
|
|
701
|
+
const blank = new DataTexture$1(new Uint8Array([
|
|
702
|
+
0,
|
|
703
|
+
0,
|
|
704
|
+
0,
|
|
705
|
+
255
|
|
706
|
+
]), 1, 1);
|
|
707
|
+
blank.needsUpdate = true;
|
|
708
|
+
return blank;
|
|
709
|
+
})();
|
|
710
|
+
/**
|
|
711
|
+
* TSL port of the image material. `ImageMaterial.ts` has the GLSL version. A fix here must go there too.
|
|
712
|
+
*/
|
|
713
|
+
var ImageNodeMaterial = class extends MeshBasicNodeMaterial {
|
|
714
|
+
_imageUniforms = {
|
|
715
|
+
scale: uniform(new Vector2$1(1, 1)),
|
|
716
|
+
imageBounds: uniform(new Vector2$1(1, 1)),
|
|
717
|
+
resolution: uniform(1024),
|
|
718
|
+
zoom: uniform(imageDefaults.zoom),
|
|
719
|
+
radius: uniform(imageDefaults.radius),
|
|
720
|
+
grayscale: uniform(imageDefaults.grayscale)
|
|
721
|
+
};
|
|
722
|
+
_map = null;
|
|
723
|
+
_mapNode;
|
|
724
|
+
constructor() {
|
|
725
|
+
super();
|
|
726
|
+
this.fog = false;
|
|
727
|
+
this.color.set(imageDefaults.color);
|
|
728
|
+
this.opacity = imageDefaults.opacity;
|
|
729
|
+
const u = this._imageUniforms;
|
|
730
|
+
const vUv = uv();
|
|
731
|
+
const aspect = (size) => size.div(min(size.x, size.y));
|
|
732
|
+
const plane = aspect(u.scale);
|
|
733
|
+
const image = aspect(u.imageBounds);
|
|
734
|
+
const imageIsWider = plane.x.div(plane.y).lessThan(image.x.div(image.y));
|
|
735
|
+
const fitted = select(imageIsWider, vec2(image.x.mul(plane.y).div(image.y), plane.y), vec2(plane.x, image.y.mul(plane.x).div(image.x)));
|
|
736
|
+
const offset = select(imageIsWider, vec2(fitted.x.sub(plane.x).div(2), 0), vec2(0, fitted.y.sub(plane.y).div(2))).div(fitted);
|
|
737
|
+
const zoomedUv = vUv.mul(plane).div(fitted).add(offset).sub(.5).div(u.zoom).add(.5);
|
|
738
|
+
const planePixels = u.scale.mul(u.resolution);
|
|
739
|
+
const halfPlanePixels = planePixels.mul(.5);
|
|
740
|
+
const cornerRadius = u.resolution.mul(u.radius);
|
|
741
|
+
const boxDistance = length(max(abs(vUv.mul(planePixels).sub(halfPlanePixels)).sub(halfPlanePixels).add(cornerRadius), 0)).sub(cornerRadius);
|
|
742
|
+
const cornerAlpha = float(1).sub(smoothstep(0, 1, boxDistance));
|
|
743
|
+
this._mapNode = texture(emptyTexture, zoomedUv);
|
|
744
|
+
const colorUniform = materialReference("color", "color");
|
|
745
|
+
const color = this._mapNode.mul(vec4(colorUniform, cornerAlpha));
|
|
746
|
+
const luma = dot(color.rgb, vec3(.299, .587, .114));
|
|
747
|
+
this.colorNode = vec4(mix(color.rgb, vec3(luma), u.grayscale), color.a);
|
|
748
|
+
Object.defineProperty(this, "map", {
|
|
749
|
+
configurable: true,
|
|
750
|
+
get: () => this._map,
|
|
751
|
+
set: (value) => {
|
|
752
|
+
this._map = value;
|
|
753
|
+
this._mapNode.value = value ?? emptyTexture;
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
copy(source) {
|
|
758
|
+
const { colorNode } = this;
|
|
759
|
+
super.copy(source);
|
|
760
|
+
this.colorNode = colorNode;
|
|
761
|
+
this.scale.copy(source.scale);
|
|
762
|
+
this.imageBounds.copy(source.imageBounds);
|
|
763
|
+
this.map = source.map;
|
|
764
|
+
return this;
|
|
765
|
+
}
|
|
766
|
+
get scale() {
|
|
767
|
+
return this._imageUniforms.scale.value;
|
|
768
|
+
}
|
|
769
|
+
get imageBounds() {
|
|
770
|
+
return this._imageUniforms.imageBounds.value;
|
|
771
|
+
}
|
|
772
|
+
get resolution() {
|
|
773
|
+
return this._imageUniforms.resolution.value;
|
|
774
|
+
}
|
|
775
|
+
set resolution(value) {
|
|
776
|
+
this._imageUniforms.resolution.value = value;
|
|
777
|
+
}
|
|
778
|
+
get zoom() {
|
|
779
|
+
return this._imageUniforms.zoom.value;
|
|
780
|
+
}
|
|
781
|
+
set zoom(value) {
|
|
782
|
+
this._imageUniforms.zoom.value = value;
|
|
783
|
+
}
|
|
784
|
+
get radius() {
|
|
785
|
+
return this._imageUniforms.radius.value;
|
|
786
|
+
}
|
|
787
|
+
set radius(value) {
|
|
788
|
+
this._imageUniforms.radius.value = value;
|
|
789
|
+
}
|
|
790
|
+
get grayscale() {
|
|
791
|
+
return this._imageUniforms.grayscale.value;
|
|
792
|
+
}
|
|
793
|
+
set grayscale(value) {
|
|
794
|
+
this._imageUniforms.grayscale.value = value;
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
//#endregion
|
|
798
|
+
//#region src/core/objects/Image/webgpu.vue?vue&type=script&setup=true&lang.ts
|
|
799
|
+
const _hoisted_1$4 = ["scale"];
|
|
800
|
+
const _hoisted_2$2 = ["args"];
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/core/objects/Image/webgpu.vue
|
|
803
|
+
var webgpu_default$3 = /* @__PURE__ */ defineComponent({
|
|
804
|
+
__name: "webgpu",
|
|
805
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
806
|
+
segments: {
|
|
807
|
+
type: Number,
|
|
808
|
+
required: false
|
|
809
|
+
},
|
|
810
|
+
scale: {
|
|
811
|
+
type: [Number, Array],
|
|
812
|
+
required: false
|
|
813
|
+
},
|
|
814
|
+
color: {
|
|
815
|
+
type: null,
|
|
816
|
+
required: false
|
|
817
|
+
},
|
|
818
|
+
zoom: {
|
|
819
|
+
type: Number,
|
|
820
|
+
required: false
|
|
821
|
+
},
|
|
822
|
+
radius: {
|
|
823
|
+
type: Number,
|
|
824
|
+
required: false
|
|
825
|
+
},
|
|
826
|
+
grayscale: {
|
|
827
|
+
type: Number,
|
|
828
|
+
required: false
|
|
829
|
+
},
|
|
830
|
+
toneMapped: {
|
|
831
|
+
type: Boolean,
|
|
832
|
+
required: false
|
|
833
|
+
},
|
|
834
|
+
transparent: {
|
|
835
|
+
type: Boolean,
|
|
836
|
+
required: false
|
|
837
|
+
},
|
|
838
|
+
opacity: {
|
|
839
|
+
type: Number,
|
|
840
|
+
required: false
|
|
841
|
+
},
|
|
842
|
+
side: {
|
|
843
|
+
type: null,
|
|
844
|
+
required: false
|
|
845
|
+
},
|
|
846
|
+
texture: {
|
|
847
|
+
type: null,
|
|
848
|
+
required: false
|
|
849
|
+
},
|
|
850
|
+
url: {
|
|
851
|
+
type: null,
|
|
852
|
+
required: false
|
|
853
|
+
}
|
|
854
|
+
}, imageDefaults),
|
|
855
|
+
setup(__props, { expose: __expose }) {
|
|
856
|
+
const props = __props;
|
|
857
|
+
extend({ ImageNodeMaterial });
|
|
858
|
+
const imageRef = shallowRef();
|
|
859
|
+
const { materialProps, scale } = useImage(props);
|
|
860
|
+
__expose({ instance: imageRef });
|
|
861
|
+
return (_ctx, _cache) => {
|
|
862
|
+
return openBlock(), createElementBlock("TresMesh", {
|
|
863
|
+
ref_key: "imageRef",
|
|
864
|
+
ref: imageRef,
|
|
865
|
+
scale: unref(scale)
|
|
866
|
+
}, [
|
|
867
|
+
renderSlot(_ctx.$slots, "default", {}, () => [createElementVNode("TresPlaneGeometry", { args: [
|
|
868
|
+
1,
|
|
869
|
+
1,
|
|
870
|
+
props.segments,
|
|
871
|
+
props.segments
|
|
872
|
+
] }, null, 8, _hoisted_2$2)]),
|
|
873
|
+
createCommentVNode(" WebGPURenderer tone-maps the whole frame, so it ignores `toneMapped`. "),
|
|
874
|
+
createElementVNode("TresImageNodeMaterial", normalizeProps(guardReactiveProps(unref(materialProps))), null, 16)
|
|
875
|
+
], 8, _hoisted_1$4);
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region src/core/shapes/Grid/GridNodeMaterial.ts
|
|
881
|
+
var GridNodeMaterial = class extends MeshBasicNodeMaterial {
|
|
882
|
+
gridUniforms = {
|
|
883
|
+
cellSize: uniform(gridDefaults.cellSize),
|
|
884
|
+
sectionSize: uniform(gridDefaults.sectionSize),
|
|
885
|
+
fadeDistance: uniform(gridDefaults.fadeDistance),
|
|
886
|
+
fadeStrength: uniform(gridDefaults.fadeStrength),
|
|
887
|
+
fadeFrom: uniform(gridDefaults.fadeFrom),
|
|
888
|
+
cellThickness: uniform(gridDefaults.cellThickness),
|
|
889
|
+
sectionThickness: uniform(gridDefaults.sectionThickness),
|
|
890
|
+
cellColor: uniform(new Color$1(gridDefaults.cellColor)),
|
|
891
|
+
sectionColor: uniform(new Color$1(gridDefaults.sectionColor)),
|
|
892
|
+
infiniteGrid: uniform(Number(gridDefaults.infiniteGrid)),
|
|
893
|
+
followCamera: uniform(Number(gridDefaults.followCamera)),
|
|
894
|
+
worldCamProjPosition: uniform(new Vector3$1()),
|
|
895
|
+
worldPlanePosition: uniform(new Vector3$1())
|
|
896
|
+
};
|
|
897
|
+
constructor() {
|
|
898
|
+
super();
|
|
899
|
+
this.transparent = true;
|
|
900
|
+
this.fog = false;
|
|
901
|
+
const u = this.gridUniforms;
|
|
902
|
+
const scaled = positionGeometry.xzy.mul(mix(float(1), u.fadeDistance.add(1), u.infiniteGrid));
|
|
903
|
+
const cameraOffset = u.worldCamProjPosition.sub(u.worldPlanePosition).mul(u.followCamera);
|
|
904
|
+
const world = modelWorldMatrix.mul(vec4(scaled, 1)).xyz.add(cameraOffset);
|
|
905
|
+
const local = modelWorldMatrixInverse.mul(vec4(world, 1)).xyz;
|
|
906
|
+
this.positionNode = local;
|
|
907
|
+
const localPosition = local.toVarying();
|
|
908
|
+
const worldPosition = world.toVarying();
|
|
909
|
+
const getGrid = (size, thickness) => {
|
|
910
|
+
const r = localPosition.xz.div(size);
|
|
911
|
+
const grid = abs(fract(r.sub(.5)).sub(.5)).div(fwidth(r));
|
|
912
|
+
const line = min(grid.x, grid.y).add(1).sub(thickness);
|
|
913
|
+
return float(1).sub(min(line, 1));
|
|
914
|
+
};
|
|
915
|
+
this.colorNode = Fn(() => {
|
|
916
|
+
const g1 = getGrid(u.cellSize, u.cellThickness).toVar();
|
|
917
|
+
const g2 = getGrid(u.sectionSize, u.sectionThickness).toVar();
|
|
918
|
+
const from = u.worldCamProjPosition.mul(u.fadeFrom);
|
|
919
|
+
const d = float(1).sub(min(distance(from, worldPosition).div(u.fadeDistance), 1));
|
|
920
|
+
const color = mix(u.cellColor, u.sectionColor, min(1, u.sectionThickness.mul(g2)));
|
|
921
|
+
const alpha = g1.add(g2).mul(pow(d, u.fadeStrength)).toVar();
|
|
922
|
+
alpha.assign(mix(alpha.mul(.75), alpha, g2));
|
|
923
|
+
If(alpha.lessThanEqual(0), () => {
|
|
924
|
+
Discard();
|
|
925
|
+
});
|
|
926
|
+
return vec4(color, alpha);
|
|
927
|
+
})();
|
|
928
|
+
}
|
|
929
|
+
get cellSize() {
|
|
930
|
+
return this.gridUniforms.cellSize.value;
|
|
931
|
+
}
|
|
932
|
+
set cellSize(value) {
|
|
933
|
+
this.gridUniforms.cellSize.value = value;
|
|
934
|
+
}
|
|
935
|
+
get sectionSize() {
|
|
936
|
+
return this.gridUniforms.sectionSize.value;
|
|
937
|
+
}
|
|
938
|
+
set sectionSize(value) {
|
|
939
|
+
this.gridUniforms.sectionSize.value = value;
|
|
940
|
+
}
|
|
941
|
+
get fadeDistance() {
|
|
942
|
+
return this.gridUniforms.fadeDistance.value;
|
|
943
|
+
}
|
|
944
|
+
set fadeDistance(value) {
|
|
945
|
+
this.gridUniforms.fadeDistance.value = value;
|
|
946
|
+
}
|
|
947
|
+
get fadeStrength() {
|
|
948
|
+
return this.gridUniforms.fadeStrength.value;
|
|
949
|
+
}
|
|
950
|
+
set fadeStrength(value) {
|
|
951
|
+
this.gridUniforms.fadeStrength.value = value;
|
|
952
|
+
}
|
|
953
|
+
get fadeFrom() {
|
|
954
|
+
return this.gridUniforms.fadeFrom.value;
|
|
955
|
+
}
|
|
956
|
+
set fadeFrom(value) {
|
|
957
|
+
this.gridUniforms.fadeFrom.value = value;
|
|
958
|
+
}
|
|
959
|
+
get cellThickness() {
|
|
960
|
+
return this.gridUniforms.cellThickness.value;
|
|
961
|
+
}
|
|
962
|
+
set cellThickness(value) {
|
|
963
|
+
this.gridUniforms.cellThickness.value = value;
|
|
964
|
+
}
|
|
965
|
+
get sectionThickness() {
|
|
966
|
+
return this.gridUniforms.sectionThickness.value;
|
|
967
|
+
}
|
|
968
|
+
set sectionThickness(value) {
|
|
969
|
+
this.gridUniforms.sectionThickness.value = value;
|
|
970
|
+
}
|
|
971
|
+
get cellColor() {
|
|
972
|
+
return this.gridUniforms.cellColor.value;
|
|
973
|
+
}
|
|
974
|
+
get sectionColor() {
|
|
975
|
+
return this.gridUniforms.sectionColor.value;
|
|
976
|
+
}
|
|
977
|
+
get infiniteGrid() {
|
|
978
|
+
return this.gridUniforms.infiniteGrid.value === 1;
|
|
979
|
+
}
|
|
980
|
+
set infiniteGrid(value) {
|
|
981
|
+
this.gridUniforms.infiniteGrid.value = value ? 1 : 0;
|
|
982
|
+
}
|
|
983
|
+
get followCamera() {
|
|
984
|
+
return this.gridUniforms.followCamera.value === 1;
|
|
985
|
+
}
|
|
986
|
+
set followCamera(value) {
|
|
987
|
+
this.gridUniforms.followCamera.value = value ? 1 : 0;
|
|
988
|
+
}
|
|
989
|
+
get worldCamProjPosition() {
|
|
990
|
+
return this.gridUniforms.worldCamProjPosition.value;
|
|
991
|
+
}
|
|
992
|
+
get worldPlanePosition() {
|
|
993
|
+
return this.gridUniforms.worldPlanePosition.value;
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
//#endregion
|
|
997
|
+
//#region src/core/shapes/Grid/webgpu.vue?vue&type=script&setup=true&lang.ts
|
|
998
|
+
const _hoisted_1$3 = ["args"];
|
|
999
|
+
//#endregion
|
|
1000
|
+
//#region src/core/shapes/Grid/webgpu.vue
|
|
1001
|
+
var webgpu_default = /* @__PURE__ */ defineComponent({
|
|
1002
|
+
__name: "webgpu",
|
|
1003
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
1004
|
+
cellSize: {
|
|
1005
|
+
type: Number,
|
|
1006
|
+
required: false
|
|
1007
|
+
},
|
|
1008
|
+
cellThickness: {
|
|
1009
|
+
type: Number,
|
|
1010
|
+
required: false
|
|
1011
|
+
},
|
|
1012
|
+
cellColor: {
|
|
1013
|
+
type: [
|
|
1014
|
+
Object,
|
|
1015
|
+
String,
|
|
1016
|
+
Number
|
|
1017
|
+
],
|
|
1018
|
+
required: false
|
|
1019
|
+
},
|
|
1020
|
+
sectionSize: {
|
|
1021
|
+
type: Number,
|
|
1022
|
+
required: false
|
|
1023
|
+
},
|
|
1024
|
+
sectionThickness: {
|
|
1025
|
+
type: Number,
|
|
1026
|
+
required: false
|
|
1027
|
+
},
|
|
1028
|
+
sectionColor: {
|
|
1029
|
+
type: [
|
|
1030
|
+
Object,
|
|
1031
|
+
String,
|
|
1032
|
+
Number
|
|
1033
|
+
],
|
|
1034
|
+
required: false
|
|
1035
|
+
},
|
|
1036
|
+
followCamera: {
|
|
1037
|
+
type: Boolean,
|
|
1038
|
+
required: false
|
|
1039
|
+
},
|
|
1040
|
+
infiniteGrid: {
|
|
1041
|
+
type: Boolean,
|
|
1042
|
+
required: false
|
|
1043
|
+
},
|
|
1044
|
+
fadeDistance: {
|
|
1045
|
+
type: Number,
|
|
1046
|
+
required: false
|
|
1047
|
+
},
|
|
1048
|
+
fadeStrength: {
|
|
1049
|
+
type: Number,
|
|
1050
|
+
required: false
|
|
1051
|
+
},
|
|
1052
|
+
fadeFrom: {
|
|
1053
|
+
type: Number,
|
|
1054
|
+
required: false
|
|
1055
|
+
},
|
|
1056
|
+
side: {
|
|
1057
|
+
type: null,
|
|
1058
|
+
required: false
|
|
1059
|
+
},
|
|
1060
|
+
args: {
|
|
1061
|
+
type: Array,
|
|
1062
|
+
required: false
|
|
1063
|
+
}
|
|
1064
|
+
}, gridDefaults),
|
|
1065
|
+
setup(__props) {
|
|
1066
|
+
const props = __props;
|
|
1067
|
+
extend({ GridNodeMaterial });
|
|
1068
|
+
const mesh = shallowRef(new Mesh());
|
|
1069
|
+
const { materialProps } = useGrid(props, mesh);
|
|
1070
|
+
return (_ctx, _cache) => {
|
|
1071
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" The material sets `transparent` itself. WebGPU needs no `extensions-derivatives`. "), createElementVNode("TresMesh", {
|
|
1072
|
+
ref_key: "mesh",
|
|
1073
|
+
ref: mesh,
|
|
1074
|
+
"frustum-culled": false
|
|
1075
|
+
}, [createElementVNode("TresGridNodeMaterial", normalizeProps(guardReactiveProps(unref(materialProps))), null, 16), createElementVNode("TresPlaneGeometry", { args: props.args }, null, 8, _hoisted_1$3)], 512)], 2112);
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
//#endregion
|
|
1080
|
+
//#region src/utils/useInstancedPoints.ts
|
|
1081
|
+
function useInstancedPoints(positions, material, { dynamic = false } = {}) {
|
|
1082
|
+
const createNode = dynamic ? instancedDynamicBufferAttribute : instancedBufferAttribute;
|
|
1083
|
+
const attribute = shallowRef(new InstancedBufferAttribute(positions.value, 3));
|
|
1084
|
+
const positionNode = shallowRef(createNode(attribute.value));
|
|
1085
|
+
const count = computed(() => attribute.value.count);
|
|
1086
|
+
watch(positions, (array) => {
|
|
1087
|
+
if (array.length === attribute.value.array.length) {
|
|
1088
|
+
attribute.value.array = array;
|
|
1089
|
+
attribute.value.needsUpdate = true;
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
attribute.value = new InstancedBufferAttribute(array, 3);
|
|
1093
|
+
positionNode.value = createNode(attribute.value);
|
|
1094
|
+
if (material.value) material.value.needsUpdate = true;
|
|
1095
|
+
});
|
|
1096
|
+
return {
|
|
1097
|
+
attribute,
|
|
1098
|
+
positionNode,
|
|
1099
|
+
count
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
//#endregion
|
|
1103
|
+
//#region src/core/staging/Precipitation/webgpu.vue?vue&type=script&setup=true&lang.ts
|
|
1104
|
+
const _hoisted_1$2 = ["count"];
|
|
1105
|
+
const _hoisted_2$1 = ["position-node"];
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/core/staging/Precipitation/webgpu.vue
|
|
1108
|
+
var webgpu_default$9 = /* @__PURE__ */ defineComponent({
|
|
1109
|
+
__name: "webgpu",
|
|
1110
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
1111
|
+
size: {
|
|
1112
|
+
type: Number,
|
|
1113
|
+
required: false
|
|
1114
|
+
},
|
|
1115
|
+
area: {
|
|
1116
|
+
type: Array,
|
|
1117
|
+
required: false
|
|
1118
|
+
},
|
|
1119
|
+
color: {
|
|
1120
|
+
type: null,
|
|
1121
|
+
required: false
|
|
1122
|
+
},
|
|
1123
|
+
map: {
|
|
1124
|
+
type: [
|
|
1125
|
+
String,
|
|
1126
|
+
Object,
|
|
1127
|
+
null
|
|
1128
|
+
],
|
|
1129
|
+
required: false
|
|
1130
|
+
},
|
|
1131
|
+
alphaMap: {
|
|
1132
|
+
type: [
|
|
1133
|
+
String,
|
|
1134
|
+
Object,
|
|
1135
|
+
null
|
|
1136
|
+
],
|
|
1137
|
+
required: false
|
|
1138
|
+
},
|
|
1139
|
+
alphaTest: {
|
|
1140
|
+
type: Number,
|
|
1141
|
+
required: false
|
|
1142
|
+
},
|
|
1143
|
+
opacity: {
|
|
1144
|
+
type: Number,
|
|
1145
|
+
required: false
|
|
1146
|
+
},
|
|
1147
|
+
count: {
|
|
1148
|
+
type: Number,
|
|
1149
|
+
required: false
|
|
1150
|
+
},
|
|
1151
|
+
speed: {
|
|
1152
|
+
type: Number,
|
|
1153
|
+
required: false
|
|
1154
|
+
},
|
|
1155
|
+
randomness: {
|
|
1156
|
+
type: Number,
|
|
1157
|
+
required: false
|
|
1158
|
+
},
|
|
1159
|
+
depthWrite: {
|
|
1160
|
+
type: Boolean,
|
|
1161
|
+
required: false
|
|
1162
|
+
},
|
|
1163
|
+
transparent: {
|
|
1164
|
+
type: Boolean,
|
|
1165
|
+
required: false
|
|
1166
|
+
},
|
|
1167
|
+
sizeAttenuation: {
|
|
1168
|
+
type: Boolean,
|
|
1169
|
+
required: false
|
|
1170
|
+
}
|
|
1171
|
+
}, precipitationDefaults),
|
|
1172
|
+
setup(__props, { expose: __expose }) {
|
|
1173
|
+
const props = __props;
|
|
1174
|
+
extend({ PointsNodeMaterial });
|
|
1175
|
+
const materialRef = shallowRef();
|
|
1176
|
+
const { positions, materialProps, onPositionsMoved } = usePrecipitation(props, materialRef);
|
|
1177
|
+
const { attribute, positionNode, count } = useInstancedPoints(positions, materialRef, { dynamic: true });
|
|
1178
|
+
onPositionsMoved(() => {
|
|
1179
|
+
attribute.value.needsUpdate = true;
|
|
1180
|
+
});
|
|
1181
|
+
const spriteRef = shallowRef();
|
|
1182
|
+
__expose({ instance: spriteRef });
|
|
1183
|
+
return (_ctx, _cache) => {
|
|
1184
|
+
return openBlock(), createElementBlock("TresSprite", {
|
|
1185
|
+
ref_key: "spriteRef",
|
|
1186
|
+
ref: spriteRef,
|
|
1187
|
+
count: unref(count),
|
|
1188
|
+
"frustum-culled": false
|
|
1189
|
+
}, [createElementVNode("TresPointsNodeMaterial", mergeProps({
|
|
1190
|
+
ref_key: "materialRef",
|
|
1191
|
+
ref: materialRef
|
|
1192
|
+
}, unref(materialProps), { "position-node": unref(positionNode) }), null, 16, _hoisted_2$1)], 8, _hoisted_1$2);
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
//#endregion
|
|
1197
|
+
//#region src/core/staging/Sparkles/SparklesNodeMaterial.ts
|
|
1198
|
+
var SparklesNodeMaterial = class extends PointsNodeMaterial {
|
|
1199
|
+
yFor;
|
|
1200
|
+
sparklesUniforms = {
|
|
1201
|
+
uNormal: uniform(Object3D$1.DEFAULT_UP.clone()),
|
|
1202
|
+
uPixelRatio: uniform(1),
|
|
1203
|
+
uNormalThreshold: uniform(sparklesDefaults.normalThreshold),
|
|
1204
|
+
uTime: uniform(0),
|
|
1205
|
+
uCooldownRatio: uniform(toCooldownRatio(sparklesDefaults.cooldownSec, sparklesDefaults.lifetimeSec)),
|
|
1206
|
+
uSize: uniform(sparklesDefaults.size),
|
|
1207
|
+
uAlpha: uniform(sparklesDefaults.alpha),
|
|
1208
|
+
uOffset: uniform(sparklesDefaults.offset),
|
|
1209
|
+
uSurfaceDistance: uniform(sparklesDefaults.surfaceDistance),
|
|
1210
|
+
uNoiseScale: uniform(toNoiseScale(sparklesDefaults.noiseScale, sparklesDefaults.lifetimeSec)),
|
|
1211
|
+
uScaleNoise: uniform(sparklesDefaults.scaleNoise),
|
|
1212
|
+
uOffsetNoise: uniform(sparklesDefaults.offsetNoise),
|
|
1213
|
+
uLifetimeNoise: uniform(sparklesDefaults.lifetimeNoise),
|
|
1214
|
+
uMixColor: uniform(sparklesDefaults.mixColor),
|
|
1215
|
+
uMixAlpha: uniform(sparklesDefaults.mixAlpha),
|
|
1216
|
+
uMixOffset: uniform(sparklesDefaults.mixOffset),
|
|
1217
|
+
uMixSize: uniform(sparklesDefaults.mixSize),
|
|
1218
|
+
uMixSurfaceDistance: uniform(sparklesDefaults.mixSurfaceDistance),
|
|
1219
|
+
uMixNoise: uniform(sparklesDefaults.mixNoise)
|
|
1220
|
+
};
|
|
1221
|
+
mapNode = texture(useEmptyDataTexture());
|
|
1222
|
+
infoNode = texture(useEmptyDataTexture());
|
|
1223
|
+
constructor(yFor) {
|
|
1224
|
+
super();
|
|
1225
|
+
this.yFor = yFor;
|
|
1226
|
+
this.fog = false;
|
|
1227
|
+
this.sizeAttenuation = false;
|
|
1228
|
+
}
|
|
1229
|
+
setGeometry(geometry) {
|
|
1230
|
+
const position = geometry.getAttribute("position");
|
|
1231
|
+
if (!position) return 0;
|
|
1232
|
+
const normal = geometry.getAttribute("normal");
|
|
1233
|
+
const index = geometry.getIndex();
|
|
1234
|
+
const { start, count: rangeCount } = geometry.drawRange;
|
|
1235
|
+
const first = Math.max(0, start);
|
|
1236
|
+
const count = Math.max(0, Math.min(index ? index.count : position.count, first + rangeCount) - first);
|
|
1237
|
+
const positions = new Float32Array(count * 3);
|
|
1238
|
+
const normals = new Float32Array(count * 3);
|
|
1239
|
+
for (let i = 0; i < count; i++) {
|
|
1240
|
+
const vertex = index ? index.getX(first + i) : first + i;
|
|
1241
|
+
positions.set([
|
|
1242
|
+
position.getX(vertex),
|
|
1243
|
+
position.getY(vertex),
|
|
1244
|
+
position.getZ(vertex)
|
|
1245
|
+
], i * 3);
|
|
1246
|
+
if (normal) normals.set([
|
|
1247
|
+
normal.getX(vertex),
|
|
1248
|
+
normal.getY(vertex),
|
|
1249
|
+
normal.getZ(vertex)
|
|
1250
|
+
], i * 3);
|
|
1251
|
+
}
|
|
1252
|
+
this.buildNodes(instancedBufferAttribute(new InstancedBufferAttribute$1(positions, 3)), instancedBufferAttribute(new InstancedBufferAttribute$1(normals, 3)));
|
|
1253
|
+
return count;
|
|
1254
|
+
}
|
|
1255
|
+
buildNodes(position, normal) {
|
|
1256
|
+
const u = this.sparklesUniforms;
|
|
1257
|
+
const yFor = this.yFor;
|
|
1258
|
+
const info = (x, row) => this.infoNode.sample(vec2(x, row)).level(float(0));
|
|
1259
|
+
const normalP = smoothstep(u.uNormalThreshold, 1, dot(normal, u.uNormal).mul(.5).add(.5));
|
|
1260
|
+
const lifetimeNoise = u.uLifetimeNoise.mul(mix(normalP, 1, u.uMixNoise));
|
|
1261
|
+
const t = u.uTime.add(position.x.mul(u.uNoiseScale)).add(position.y.mul(10).mul(u.uNoiseScale)).add(position.z.mul(7.3).mul(u.uNoiseScale)).add(sin(lifetimeNoise.mul(position.x.add(position.y.mul(13)))).mul(lifetimeNoise));
|
|
1262
|
+
const lifetimeP = max(float(-1e-4), mix(u.uCooldownRatio.negate(), cos(t).mul(lifetimeNoise).add(1), fract(t)));
|
|
1263
|
+
const progress = (mixFactor) => mix(normalP, lifetimeP, mixFactor);
|
|
1264
|
+
const surfaceDistance = info(progress(u.uMixSurfaceDistance), yFor.sequenceSurfaceDistance).x.mul(u.uSurfaceDistance);
|
|
1265
|
+
const noise = info(progress(u.uMixNoise), yFor.sequenceNoise).xyz;
|
|
1266
|
+
const offset = info(progress(u.uMixOffset), yFor.sequenceOffset).xyz.mul(2).sub(1).mul(u.uOffset);
|
|
1267
|
+
const wave = t.mul(u.uNoiseScale).mul(10);
|
|
1268
|
+
const world = modelWorldMatrix.mul(vec4(position.add(normal.mul(surfaceDistance)), 1)).xyz.add(vec3(cos(wave), sin(wave), cos(wave)).mul(u.uOffsetNoise.mul(.2)).mul(noise)).add(offset);
|
|
1269
|
+
this.positionNode = modelWorldMatrixInverse.mul(vec4(world, 1)).xyz;
|
|
1270
|
+
const viewZ = cameraViewMatrix.mul(vec4(world, 1)).z;
|
|
1271
|
+
const pointSize = float(2).mul(info(progress(u.uMixSize), yFor.sequenceSize).x).mul(mix(float(1), abs(sin(t.mul(u.uNoiseScale).add(position.x.mul(13.9)).add(position.y.mul(73.1)))), u.uScaleNoise)).mul(u.uSize).mul(float(100).div(viewZ.negate())).mul(u.uPixelRatio);
|
|
1272
|
+
const hidden = pointSize.lessThan(.6).or(lifetimeP.lessThan(0));
|
|
1273
|
+
this.sizeNode = select(hidden, float(0), pointSize.div(screenDPR));
|
|
1274
|
+
const color = info(progress(u.uMixColor), yFor.sequenceColor).mul(info(progress(u.uMixAlpha), yFor.sequenceAlpha).x).mul(u.uAlpha);
|
|
1275
|
+
this.colorNode = color.toVarying().mul(this.mapNode.sample(vec2(uv().x, uv().y.oneMinus())));
|
|
1276
|
+
this.needsUpdate = true;
|
|
1277
|
+
}
|
|
1278
|
+
get uMap() {
|
|
1279
|
+
return this.mapNode.value;
|
|
1280
|
+
}
|
|
1281
|
+
set uMap(value) {
|
|
1282
|
+
this.mapNode.value = value;
|
|
1283
|
+
}
|
|
1284
|
+
get uInfoTexture() {
|
|
1285
|
+
return this.infoNode.value;
|
|
1286
|
+
}
|
|
1287
|
+
set uInfoTexture(value) {
|
|
1288
|
+
this.infoNode.value = value;
|
|
1289
|
+
}
|
|
1290
|
+
get uNormal() {
|
|
1291
|
+
return this.sparklesUniforms.uNormal.value;
|
|
1292
|
+
}
|
|
1293
|
+
get uPixelRatio() {
|
|
1294
|
+
return this.sparklesUniforms.uPixelRatio.value;
|
|
1295
|
+
}
|
|
1296
|
+
set uPixelRatio(value) {
|
|
1297
|
+
this.sparklesUniforms.uPixelRatio.value = value;
|
|
1298
|
+
}
|
|
1299
|
+
get uNormalThreshold() {
|
|
1300
|
+
return this.sparklesUniforms.uNormalThreshold.value;
|
|
1301
|
+
}
|
|
1302
|
+
set uNormalThreshold(value) {
|
|
1303
|
+
this.sparklesUniforms.uNormalThreshold.value = value;
|
|
1304
|
+
}
|
|
1305
|
+
get uTime() {
|
|
1306
|
+
return this.sparklesUniforms.uTime.value;
|
|
1307
|
+
}
|
|
1308
|
+
set uTime(value) {
|
|
1309
|
+
this.sparklesUniforms.uTime.value = value;
|
|
1310
|
+
}
|
|
1311
|
+
get uCooldownRatio() {
|
|
1312
|
+
return this.sparklesUniforms.uCooldownRatio.value;
|
|
1313
|
+
}
|
|
1314
|
+
set uCooldownRatio(value) {
|
|
1315
|
+
this.sparklesUniforms.uCooldownRatio.value = value;
|
|
1316
|
+
}
|
|
1317
|
+
get uSize() {
|
|
1318
|
+
return this.sparklesUniforms.uSize.value;
|
|
1319
|
+
}
|
|
1320
|
+
set uSize(value) {
|
|
1321
|
+
this.sparklesUniforms.uSize.value = value;
|
|
1322
|
+
}
|
|
1323
|
+
get uAlpha() {
|
|
1324
|
+
return this.sparklesUniforms.uAlpha.value;
|
|
1325
|
+
}
|
|
1326
|
+
set uAlpha(value) {
|
|
1327
|
+
this.sparklesUniforms.uAlpha.value = value;
|
|
1328
|
+
}
|
|
1329
|
+
get uOffset() {
|
|
1330
|
+
return this.sparklesUniforms.uOffset.value;
|
|
1331
|
+
}
|
|
1332
|
+
set uOffset(value) {
|
|
1333
|
+
this.sparklesUniforms.uOffset.value = value;
|
|
1334
|
+
}
|
|
1335
|
+
get uSurfaceDistance() {
|
|
1336
|
+
return this.sparklesUniforms.uSurfaceDistance.value;
|
|
1337
|
+
}
|
|
1338
|
+
set uSurfaceDistance(value) {
|
|
1339
|
+
this.sparklesUniforms.uSurfaceDistance.value = value;
|
|
1340
|
+
}
|
|
1341
|
+
get uNoiseScale() {
|
|
1342
|
+
return this.sparklesUniforms.uNoiseScale.value;
|
|
1343
|
+
}
|
|
1344
|
+
set uNoiseScale(value) {
|
|
1345
|
+
this.sparklesUniforms.uNoiseScale.value = value;
|
|
1346
|
+
}
|
|
1347
|
+
get uScaleNoise() {
|
|
1348
|
+
return this.sparklesUniforms.uScaleNoise.value;
|
|
1349
|
+
}
|
|
1350
|
+
set uScaleNoise(value) {
|
|
1351
|
+
this.sparklesUniforms.uScaleNoise.value = value;
|
|
1352
|
+
}
|
|
1353
|
+
get uOffsetNoise() {
|
|
1354
|
+
return this.sparklesUniforms.uOffsetNoise.value;
|
|
1355
|
+
}
|
|
1356
|
+
set uOffsetNoise(value) {
|
|
1357
|
+
this.sparklesUniforms.uOffsetNoise.value = value;
|
|
1358
|
+
}
|
|
1359
|
+
get uLifetimeNoise() {
|
|
1360
|
+
return this.sparklesUniforms.uLifetimeNoise.value;
|
|
1361
|
+
}
|
|
1362
|
+
set uLifetimeNoise(value) {
|
|
1363
|
+
this.sparklesUniforms.uLifetimeNoise.value = value;
|
|
1364
|
+
}
|
|
1365
|
+
get uMixColor() {
|
|
1366
|
+
return this.sparklesUniforms.uMixColor.value;
|
|
1367
|
+
}
|
|
1368
|
+
set uMixColor(value) {
|
|
1369
|
+
this.sparklesUniforms.uMixColor.value = value;
|
|
1370
|
+
}
|
|
1371
|
+
get uMixAlpha() {
|
|
1372
|
+
return this.sparklesUniforms.uMixAlpha.value;
|
|
1373
|
+
}
|
|
1374
|
+
set uMixAlpha(value) {
|
|
1375
|
+
this.sparklesUniforms.uMixAlpha.value = value;
|
|
1376
|
+
}
|
|
1377
|
+
get uMixOffset() {
|
|
1378
|
+
return this.sparklesUniforms.uMixOffset.value;
|
|
1379
|
+
}
|
|
1380
|
+
set uMixOffset(value) {
|
|
1381
|
+
this.sparklesUniforms.uMixOffset.value = value;
|
|
1382
|
+
}
|
|
1383
|
+
get uMixSize() {
|
|
1384
|
+
return this.sparklesUniforms.uMixSize.value;
|
|
1385
|
+
}
|
|
1386
|
+
set uMixSize(value) {
|
|
1387
|
+
this.sparklesUniforms.uMixSize.value = value;
|
|
1388
|
+
}
|
|
1389
|
+
get uMixSurfaceDistance() {
|
|
1390
|
+
return this.sparklesUniforms.uMixSurfaceDistance.value;
|
|
1391
|
+
}
|
|
1392
|
+
set uMixSurfaceDistance(value) {
|
|
1393
|
+
this.sparklesUniforms.uMixSurfaceDistance.value = value;
|
|
1394
|
+
}
|
|
1395
|
+
get uMixNoise() {
|
|
1396
|
+
return this.sparklesUniforms.uMixNoise.value;
|
|
1397
|
+
}
|
|
1398
|
+
set uMixNoise(value) {
|
|
1399
|
+
this.sparklesUniforms.uMixNoise.value = value;
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
//#endregion
|
|
1403
|
+
//#region src/core/staging/Sparkles/webgpu.vue?vue&type=script&setup=true&lang.ts
|
|
1404
|
+
const _hoisted_1$1 = ["object"];
|
|
1405
|
+
//#endregion
|
|
1406
|
+
//#region src/core/staging/Sparkles/webgpu.vue
|
|
1407
|
+
var webgpu_default$10 = /* @__PURE__ */ defineComponent({
|
|
1408
|
+
__name: "webgpu",
|
|
1409
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
1410
|
+
map: {
|
|
1411
|
+
type: [Object, String],
|
|
1412
|
+
required: false
|
|
1413
|
+
},
|
|
1414
|
+
geometry: {
|
|
1415
|
+
type: Object,
|
|
1416
|
+
required: false
|
|
1417
|
+
},
|
|
1418
|
+
directionalLight: {
|
|
1419
|
+
type: Object,
|
|
1420
|
+
required: false
|
|
1421
|
+
},
|
|
1422
|
+
lifetimeSec: {
|
|
1423
|
+
type: Number,
|
|
1424
|
+
required: false
|
|
1425
|
+
},
|
|
1426
|
+
cooldownSec: {
|
|
1427
|
+
type: Number,
|
|
1428
|
+
required: false
|
|
1429
|
+
},
|
|
1430
|
+
normalThreshold: {
|
|
1431
|
+
type: Number,
|
|
1432
|
+
required: false
|
|
1433
|
+
},
|
|
1434
|
+
noiseScale: {
|
|
1435
|
+
type: Number,
|
|
1436
|
+
required: false
|
|
1437
|
+
},
|
|
1438
|
+
scaleNoise: {
|
|
1439
|
+
type: Number,
|
|
1440
|
+
required: false
|
|
1441
|
+
},
|
|
1442
|
+
offsetNoise: {
|
|
1443
|
+
type: Number,
|
|
1444
|
+
required: false
|
|
1445
|
+
},
|
|
1446
|
+
lifetimeNoise: {
|
|
1447
|
+
type: Number,
|
|
1448
|
+
required: false
|
|
1449
|
+
},
|
|
1450
|
+
size: {
|
|
1451
|
+
type: Number,
|
|
1452
|
+
required: false
|
|
1453
|
+
},
|
|
1454
|
+
alpha: {
|
|
1455
|
+
type: Number,
|
|
1456
|
+
required: false
|
|
1457
|
+
},
|
|
1458
|
+
offset: {
|
|
1459
|
+
type: Number,
|
|
1460
|
+
required: false
|
|
1461
|
+
},
|
|
1462
|
+
surfaceDistance: {
|
|
1463
|
+
type: Number,
|
|
1464
|
+
required: false
|
|
1465
|
+
},
|
|
1466
|
+
sequenceColor: {
|
|
1467
|
+
type: null,
|
|
1468
|
+
required: false
|
|
1469
|
+
},
|
|
1470
|
+
sequenceAlpha: {
|
|
1471
|
+
type: [Number, Array],
|
|
1472
|
+
required: false
|
|
1473
|
+
},
|
|
1474
|
+
sequenceOffset: {
|
|
1475
|
+
type: [
|
|
1476
|
+
Object,
|
|
1477
|
+
Array,
|
|
1478
|
+
Number
|
|
1479
|
+
],
|
|
1480
|
+
required: false
|
|
1481
|
+
},
|
|
1482
|
+
sequenceNoise: {
|
|
1483
|
+
type: [
|
|
1484
|
+
Object,
|
|
1485
|
+
Array,
|
|
1486
|
+
Number
|
|
1487
|
+
],
|
|
1488
|
+
required: false
|
|
1489
|
+
},
|
|
1490
|
+
sequenceSize: {
|
|
1491
|
+
type: [Number, Array],
|
|
1492
|
+
required: false
|
|
1493
|
+
},
|
|
1494
|
+
sequenceSurfaceDistance: {
|
|
1495
|
+
type: [Number, Array],
|
|
1496
|
+
required: false
|
|
1497
|
+
},
|
|
1498
|
+
mixColor: {
|
|
1499
|
+
type: Number,
|
|
1500
|
+
required: false
|
|
1501
|
+
},
|
|
1502
|
+
mixAlpha: {
|
|
1503
|
+
type: Number,
|
|
1504
|
+
required: false
|
|
1505
|
+
},
|
|
1506
|
+
mixOffset: {
|
|
1507
|
+
type: Number,
|
|
1508
|
+
required: false
|
|
1509
|
+
},
|
|
1510
|
+
mixSize: {
|
|
1511
|
+
type: Number,
|
|
1512
|
+
required: false
|
|
1513
|
+
},
|
|
1514
|
+
mixSurfaceDistance: {
|
|
1515
|
+
type: Number,
|
|
1516
|
+
required: false
|
|
1517
|
+
},
|
|
1518
|
+
mixNoise: {
|
|
1519
|
+
type: Number,
|
|
1520
|
+
required: false
|
|
1521
|
+
},
|
|
1522
|
+
blending: {
|
|
1523
|
+
type: null,
|
|
1524
|
+
required: false
|
|
1525
|
+
},
|
|
1526
|
+
transparent: {
|
|
1527
|
+
type: Boolean,
|
|
1528
|
+
required: false
|
|
1529
|
+
},
|
|
1530
|
+
depthWrite: {
|
|
1531
|
+
type: Boolean,
|
|
1532
|
+
required: false
|
|
1533
|
+
}
|
|
1534
|
+
}, sparklesDefaults),
|
|
1535
|
+
setup(__props, { expose: __expose }) {
|
|
1536
|
+
const { object: sparkles } = useSparkles(__props, (yFor) => {
|
|
1537
|
+
const material = new SparklesNodeMaterial(yFor);
|
|
1538
|
+
const sprite = new Sprite(material);
|
|
1539
|
+
sprite.geometry = sprite.geometry.clone();
|
|
1540
|
+
sprite.count = 0;
|
|
1541
|
+
sprite.frustumCulled = false;
|
|
1542
|
+
sprite.raycast = () => {};
|
|
1543
|
+
return {
|
|
1544
|
+
object: sprite,
|
|
1545
|
+
material,
|
|
1546
|
+
setGeometry: (geometry) => {
|
|
1547
|
+
sprite.count = material.setGeometry(geometry);
|
|
1548
|
+
}
|
|
1549
|
+
};
|
|
1550
|
+
});
|
|
1551
|
+
__expose({ instance: sparkles });
|
|
1552
|
+
return (_ctx, _cache) => {
|
|
1553
|
+
return openBlock(), createElementBlock("primitive", { object: unref(sparkles) }, null, 8, _hoisted_1$1);
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1557
|
+
//#endregion
|
|
1558
|
+
//#region src/core/staging/Stars/webgpu.vue?vue&type=script&setup=true&lang.ts
|
|
1559
|
+
const _hoisted_1 = ["count"];
|
|
1560
|
+
const _hoisted_2 = ["position-node"];
|
|
1561
|
+
//#endregion
|
|
1562
|
+
//#region src/core/staging/Stars/webgpu.vue
|
|
1563
|
+
var webgpu_default$11 = /* @__PURE__ */ defineComponent({
|
|
1564
|
+
__name: "webgpu",
|
|
1565
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
1566
|
+
size: {
|
|
1567
|
+
type: Number,
|
|
1568
|
+
required: false
|
|
1569
|
+
},
|
|
1570
|
+
sizeAttenuation: {
|
|
1571
|
+
type: Boolean,
|
|
1572
|
+
required: false
|
|
1573
|
+
},
|
|
1574
|
+
transparent: {
|
|
1575
|
+
type: Boolean,
|
|
1576
|
+
required: false
|
|
1577
|
+
},
|
|
1578
|
+
alphaTest: {
|
|
1579
|
+
type: Number,
|
|
1580
|
+
required: false
|
|
1581
|
+
},
|
|
1582
|
+
count: {
|
|
1583
|
+
type: Number,
|
|
1584
|
+
required: false
|
|
1585
|
+
},
|
|
1586
|
+
depth: {
|
|
1587
|
+
type: Number,
|
|
1588
|
+
required: false
|
|
1589
|
+
},
|
|
1590
|
+
radius: {
|
|
1591
|
+
type: Number,
|
|
1592
|
+
required: false
|
|
1593
|
+
},
|
|
1594
|
+
alphaMap: {
|
|
1595
|
+
type: [Object, null],
|
|
1596
|
+
required: false
|
|
1597
|
+
}
|
|
1598
|
+
}, starsDefaults),
|
|
1599
|
+
setup(__props, { expose: __expose }) {
|
|
1600
|
+
const props = __props;
|
|
1601
|
+
extend({ PointsNodeMaterial });
|
|
1602
|
+
const materialRef = shallowRef();
|
|
1603
|
+
const { positions, materialProps } = useStars(props, materialRef);
|
|
1604
|
+
const { positionNode, count } = useInstancedPoints(positions, materialRef);
|
|
1605
|
+
const starsRef = shallowRef();
|
|
1606
|
+
__expose({ instance: starsRef });
|
|
1607
|
+
return (_ctx, _cache) => {
|
|
1608
|
+
return openBlock(), createElementBlock("TresSprite", {
|
|
1609
|
+
ref_key: "starsRef",
|
|
1610
|
+
ref: starsRef,
|
|
1611
|
+
count: unref(count),
|
|
1612
|
+
"frustum-culled": false
|
|
1613
|
+
}, [createElementVNode("TresPointsNodeMaterial", mergeProps({
|
|
1614
|
+
ref_key: "materialRef",
|
|
1615
|
+
ref: materialRef
|
|
1616
|
+
}, unref(materialProps), { "position-node": unref(positionNode) }), null, 16, _hoisted_2)], 8, _hoisted_1);
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
//#endregion
|
|
1621
|
+
export { Align_default as Align, component_default as AnimatedSprite, Backdrop_default as Backdrop, BaseCameraControls, Billboard_default as Billboard, component_default$1 as Bounds, Box_default as Box, CameraControls_default as CameraControls, CameraShake_default as CameraShake, Circle_default as Circle, CircleShadow_default as CircleShadow, Cone_default as Cone, component_default$2 as CubeCamera, Cylinder_default as Cylinder, Decal_default as Decal, DecalDebugUI_default as DecalDebugUI, Dodecahedron_default as Dodecahedron, Edges_default as Edges, component_default$3 as Environment, component_default$4 as FBXModel, component_default$5 as Fbo, Fit_default as Fit, component_default$6 as GLTFModel, GlobalAudio, GradientTexture_default as GradientTexture, webgpu_default as Grid, component_default$7 as Helper, webgpu_default$1 as HolographicMaterial, webgpu_default$2 as Html, INSTANCES_INJECTION_KEY, Icosahedron_default as Icosahedron, webgpu_default$3 as Image, Instance_default as Instance, Instances_default as Instances, KeyboardControls_default as KeyboardControls, LOD_default as LOD, Levioso_default as Levioso, lightformer_default as Lightformer, MERGED_INJECTION_KEY, MapControls_default as MapControls, MarchingCube_default as MarchingCube, MarchingCubes_default as MarchingCubes, MarchingPlane_default as MarchingPlane, component_default$8 as Mask, Merged_default as Merged, webgpu_default$4 as MeshDiscardMaterial, webgpu_default$5 as MeshGlassMaterial, webgpu_default$6 as MeshWobbleMaterial, MouseParallax_default as MouseParallax, Octahedron_default as Octahedron, OrbitControls_default as OrbitControls, webgpu_default$7 as Outline, Plane_default as Plane, webgpu_default$8 as PointMaterial, PointerLockControls_default as PointerLockControls, PositionMesh, PositionalAudio_default as PositionalAudio, webgpu_default$9 as Precipitation, component_default$9 as RandomizedLights, Ring_default as Ring, RoundedBox_default as RoundedBox, RoundedPlane_default as RoundedPlane, component_default$10 as Sampler, ScreenQuad_default as ScreenQuad, ScreenSizer_default as ScreenSizer, ScreenSpace_default as ScreenSpace, ScrollControls_default as ScrollControls, Smoke_default as Smoke, webgpu_default$10 as Sparkles, Sphere_default as Sphere, webgpu_default$11 as Stars, Stats, StatsGl, Superformula_default as Superformula, Tetrahedron_default as Tetrahedron, Text3D_default as Text3D, Torus_default as Torus, TorusKnot_default as TorusKnot, TransformControls_default as TransformControls, Tube_default as Tube, component_default$11 as UseSVG, component_default$12 as UseTexture, ensureTextureNames, extractBindingPosition, getTextureAspect, getTextureName, hasSetter, invalidateDecalGeometry, pick, useAnimations, useBVH, useDecalEditor, useEnvironment, useFBO, useFBX, useGLTF, useGLTFExporter, useHelper, useIntersect, useMask, useProgress, useSVG, useSurfaceSampler, useTexture, useTextures, useVideoTexture };
|