@3driseai/3drise-viewer 0.1.18 → 0.1.20
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/components/AnimatedObject.d.ts.map +1 -1
- package/dist/components/AnimatedObject.js +3 -2
- package/dist/components/CreatedObject.d.ts.map +1 -1
- package/dist/components/CreatedObject.js +18 -14
- package/dist/components/ModelMaterialPassContext.d.ts +7 -0
- package/dist/components/ModelMaterialPassContext.d.ts.map +1 -0
- package/dist/components/ModelMaterialPassContext.js +7 -0
- package/dist/components/ModelPrimitive.d.ts.map +1 -1
- package/dist/components/ModelPrimitive.js +7 -1
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +10 -6
- package/dist/components/ParticlesGenerator.d.ts.map +1 -1
- package/dist/components/ParticlesGenerator.js +11 -5
- package/dist/components/particles/BioluminescentWakeParticles.d.ts +5 -2
- package/dist/components/particles/BioluminescentWakeParticles.d.ts.map +1 -1
- package/dist/components/particles/BioluminescentWakeParticles.js +28 -6
- package/dist/components/particles/BrownianDustParticles.d.ts +5 -2
- package/dist/components/particles/BrownianDustParticles.d.ts.map +1 -1
- package/dist/components/particles/BrownianDustParticles.js +28 -6
- package/dist/components/particles/ChladniSandParticles.d.ts +15 -0
- package/dist/components/particles/ChladniSandParticles.d.ts.map +1 -0
- package/dist/components/particles/ChladniSandParticles.js +912 -0
- package/dist/components/particles/ElectronOrbitalsParticles.d.ts +5 -2
- package/dist/components/particles/ElectronOrbitalsParticles.d.ts.map +1 -1
- package/dist/components/particles/ElectronOrbitalsParticles.js +28 -6
- package/dist/components/particles/FaradayPowderParticles.d.ts +15 -0
- package/dist/components/particles/FaradayPowderParticles.d.ts.map +1 -0
- package/dist/components/particles/FaradayPowderParticles.js +783 -0
- package/dist/components/particles/GrinderSparksParticles.d.ts +5 -2
- package/dist/components/particles/GrinderSparksParticles.d.ts.map +1 -1
- package/dist/components/particles/GrinderSparksParticles.js +37 -13
- package/dist/components/particles/NeonRainParticles.d.ts +15 -0
- package/dist/components/particles/NeonRainParticles.d.ts.map +1 -0
- package/dist/components/particles/NeonRainParticles.js +716 -0
- package/dist/components/particles/TidalStreamParticles.d.ts +5 -2
- package/dist/components/particles/TidalStreamParticles.d.ts.map +1 -1
- package/dist/components/particles/TidalStreamParticles.js +28 -6
- package/dist/components/particles/index.d.ts +6 -0
- package/dist/components/particles/index.d.ts.map +1 -1
- package/dist/components/particles/index.js +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useConfigLive.d.ts +54 -0
- package/dist/hooks/useConfigLive.d.ts.map +1 -0
- package/dist/hooks/useConfigLive.js +100 -0
- package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
- package/dist/hooks/useMaterialApplication.js +1 -0
- package/dist/hooks/useNodeOverrides.d.ts +13 -0
- package/dist/hooks/useNodeOverrides.d.ts.map +1 -0
- package/dist/hooks/useNodeOverrides.js +254 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/utils/configAnimations.d.ts +43 -0
- package/dist/utils/configAnimations.d.ts.map +1 -0
- package/dist/utils/configAnimations.js +73 -0
- package/dist/utils/particleTrails.d.ts.map +1 -1
- package/dist/utils/particleTrails.js +17 -8
- package/package.json +2 -2
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG1F,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG5F,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,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AE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export { buildTextureArray, decodeHeightmap, loadImage } from './utils/landscape
|
|
|
26
26
|
export { applyOceanUniforms, buildWaveTable, seaState } from './utils/oceanUniforms.js';
|
|
27
27
|
export { applyCameraUniforms, applyCirrusUniforms, applyDeckUniforms, applySunUniforms, applyThunderUniforms, } from './utils/cloudUniforms.js';
|
|
28
28
|
export { applyCloudsKeyframeAnimations, applyCloudsMouseMove, resolveDeckConfig, } from './utils/handleCloudsAnimations.js';
|
|
29
|
+
export { applyConfigKeyframeAnimations, applyConfigMouseMove, hasConfigOverrides, resolveConfig, } from './utils/configAnimations.js';
|
|
29
30
|
// Presets
|
|
30
31
|
export { volumetricCloudPresets, cirrusPresets, getCloudPresetsForType, getCloudPresetByName, getCirrusPresetByName, searchCloudPresetsByTags, } from './presets/volumetricCloudPresets.js';
|
|
31
32
|
export { terrainPresets, getTerrainPresetsForType, getTerrainPresetByName, searchTerrainPresetsByTags, } from './presets/terrainPresets.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AnimationOptions, MouseMoveProperty } from '@3driseai/3drise-core';
|
|
2
|
+
/**
|
|
3
|
+
* Keyframe animations and mouse-move, applied to a *config object* rather than to
|
|
4
|
+
* materials — the shape every generative family shares (particles, effects, and the
|
|
5
|
+
* clouds / rain helpers this generalises).
|
|
6
|
+
*
|
|
7
|
+
* The renderer keeps one override record per frame and lays it over the committed
|
|
8
|
+
* config before pushing uniforms:
|
|
9
|
+
*
|
|
10
|
+
* applyConfigKeyframeAnimations(anims, startValues, config, override, elapsedMs, ANIMATABLE);
|
|
11
|
+
* applyConfig(uniforms, { ...config, ...live, ...override }, size);
|
|
12
|
+
*
|
|
13
|
+
* Only knobs in `allowed` are eligible: that set is generated from the component's
|
|
14
|
+
* own applyConfig (see core's GENERATIVE_ANIMATABLE), so a keyframe can never target
|
|
15
|
+
* something that would need a rebuild to take effect.
|
|
16
|
+
*
|
|
17
|
+
* Both numbers and colours work — `interpolateValue` is type-aware and reads hex
|
|
18
|
+
* strings as colours.
|
|
19
|
+
*/
|
|
20
|
+
export type ConfigOverride = Record<string, number | string>;
|
|
21
|
+
/** Cache of the value a property started at, so `from`-less keyframes have an origin. */
|
|
22
|
+
export type ConfigStartValues = Record<string, number | string>;
|
|
23
|
+
/**
|
|
24
|
+
* @param elapsedMs Milliseconds since this animation set started — NOT `Date.now()`,
|
|
25
|
+
* and not seconds. `calculateTimeProgress` divides by `duration`, so a wall
|
|
26
|
+
* clock makes a one-shot finish on its first frame, and seconds make it crawl.
|
|
27
|
+
* Reset the origin (and `startValues`) whenever the animation list changes, so
|
|
28
|
+
* editing a keyframe restarts it instead of dropping the user mid-cycle.
|
|
29
|
+
*
|
|
30
|
+
* Clears `override` first: a keyframe that was removed must stop driving its knob.
|
|
31
|
+
* Call this before `applyConfigMouseMove`, which layers on top.
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyConfigKeyframeAnimations(animations: AnimationOptions[] | undefined, startValues: ConfigStartValues, config: Record<string, unknown>, override: ConfigOverride, elapsedMs: number, allowed?: ReadonlySet<string>): void;
|
|
34
|
+
/** Pointer-driven overrides, layered on top of whatever the keyframes produced. */
|
|
35
|
+
export declare function applyConfigMouseMove(properties: MouseMoveProperty[] | undefined, config: Record<string, unknown>, override: ConfigOverride, pointer: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
}, allowed?: ReadonlySet<string>): void;
|
|
39
|
+
/** True when anything is currently being driven. */
|
|
40
|
+
export declare function hasConfigOverrides(override: ConfigOverride): boolean;
|
|
41
|
+
/** Merge overrides into a config, returning the original when nothing is driving it. */
|
|
42
|
+
export declare function resolveConfig<T extends object>(config: T, ...overrides: (ConfigOverride | undefined)[]): T;
|
|
43
|
+
//# sourceMappingURL=configAnimations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configAnimations.d.ts","sourceRoot":"","sources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Easing, gsapEasingMap, interpolateValue, interpolateMouseMoveProperty } from '@3driseai/3drise-core';
|
|
2
|
+
/**
|
|
3
|
+
* @param elapsedMs Milliseconds since this animation set started — NOT `Date.now()`,
|
|
4
|
+
* and not seconds. `calculateTimeProgress` divides by `duration`, so a wall
|
|
5
|
+
* clock makes a one-shot finish on its first frame, and seconds make it crawl.
|
|
6
|
+
* Reset the origin (and `startValues`) whenever the animation list changes, so
|
|
7
|
+
* editing a keyframe restarts it instead of dropping the user mid-cycle.
|
|
8
|
+
*
|
|
9
|
+
* Clears `override` first: a keyframe that was removed must stop driving its knob.
|
|
10
|
+
* Call this before `applyConfigMouseMove`, which layers on top.
|
|
11
|
+
*/
|
|
12
|
+
export function applyConfigKeyframeAnimations(animations, startValues, config, override, elapsedMs, allowed) {
|
|
13
|
+
for (const k of Object.keys(override))
|
|
14
|
+
delete override[k];
|
|
15
|
+
if (!animations?.length)
|
|
16
|
+
return;
|
|
17
|
+
for (const anim of animations) {
|
|
18
|
+
const { property, to, duration, ease, loop = false, yoyo = false, active } = anim;
|
|
19
|
+
if (active === false || to === undefined)
|
|
20
|
+
continue;
|
|
21
|
+
if (allowed && !allowed.has(property))
|
|
22
|
+
continue;
|
|
23
|
+
let from = anim.from;
|
|
24
|
+
if (from === undefined) {
|
|
25
|
+
from = startValues[property] ??= config[property];
|
|
26
|
+
}
|
|
27
|
+
if (from === undefined || from === null)
|
|
28
|
+
continue;
|
|
29
|
+
let p = calculateTimeProgress(elapsedMs, duration, yoyo, loop);
|
|
30
|
+
if (ease) {
|
|
31
|
+
const fn = gsapEasingMap[ease] || ease;
|
|
32
|
+
p = applyEasing(fn, p);
|
|
33
|
+
}
|
|
34
|
+
override[property] = interpolateValue(property, from, to, p);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Pointer-driven overrides, layered on top of whatever the keyframes produced. */
|
|
38
|
+
export function applyConfigMouseMove(properties, config, override, pointer, allowed) {
|
|
39
|
+
if (!properties?.length)
|
|
40
|
+
return;
|
|
41
|
+
for (const { property, enabled, propertySettings } of properties) {
|
|
42
|
+
if (!enabled)
|
|
43
|
+
continue;
|
|
44
|
+
if (allowed && !allowed.has(property))
|
|
45
|
+
continue;
|
|
46
|
+
const { axis = 'both', sensitivity = 1, inverted = false, min, max } = propertySettings || {};
|
|
47
|
+
// Compose with the keyframed value when there is one, so the two stack instead
|
|
48
|
+
// of the pointer snapping back to the config every frame.
|
|
49
|
+
const base = override[property] ?? config[property];
|
|
50
|
+
if (base === undefined)
|
|
51
|
+
continue;
|
|
52
|
+
override[property] = interpolateMouseMoveProperty(base, min, max, pointer, axis, sensitivity, inverted);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** True when anything is currently being driven. */
|
|
56
|
+
export function hasConfigOverrides(override) {
|
|
57
|
+
for (const k in override)
|
|
58
|
+
if (override[k] !== undefined)
|
|
59
|
+
return true;
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
/** Merge overrides into a config, returning the original when nothing is driving it. */
|
|
63
|
+
export function resolveConfig(config, ...overrides) {
|
|
64
|
+
let dirty = false;
|
|
65
|
+
for (const o of overrides)
|
|
66
|
+
if (o && hasConfigOverrides(o)) {
|
|
67
|
+
dirty = true;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (!dirty)
|
|
71
|
+
return config;
|
|
72
|
+
return Object.assign({}, config, ...overrides.filter(Boolean));
|
|
73
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particleTrails.d.ts","sourceRoot":"","sources":["../../src/utils/particleTrails.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,eAAO,MAAM,WAAW,UAAsC,CAAC;AAK/D,wBAAgB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;EAWlC;AAED,wBAAgB,gBAAgB,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,QAKpC;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,MAAM,KAAA;;;YAES,CAAC,MAAM,CAAC,MAAM,CAAC,SAAU;YAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS;YAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAQ;;;;;;;;;;;;;;;;;;;;EAMjH;
|
|
1
|
+
{"version":3,"file":"particleTrails.d.ts","sourceRoot":"","sources":["../../src/utils/particleTrails.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,eAAO,MAAM,WAAW,UAAsC,CAAC;AAK/D,wBAAgB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;EAWlC;AAED,wBAAgB,gBAAgB,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,QAKpC;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,MAAM,KAAA;;;YAES,CAAC,MAAM,CAAC,MAAM,CAAC,SAAU;YAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS;YAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAQ;;;;;;;;;;;;;;;;;;;;EAMjH;AAuID;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA;;;;;;;EAyJxC"}
|
|
@@ -94,6 +94,13 @@ function finish(sizePx) {
|
|
|
94
94
|
gl_Position = projectionMatrix * vec4(mv, 1.0);
|
|
95
95
|
`;
|
|
96
96
|
}
|
|
97
|
+
// The per-vertex template parameter lives in its own attribute (aT). `position` must exist for
|
|
98
|
+
// InstancedBufferGeometry to draw, but it stays all zeros: Box3.expandByObject(obj, true) reads it,
|
|
99
|
+
// and a 0..10 template in position.x would drag an editor's selection gizmo ten units sideways.
|
|
100
|
+
function setTemplate(g, tpl) {
|
|
101
|
+
g.setAttribute('position', new THREE.BufferAttribute(new Float32Array(tpl.length * 3), 3));
|
|
102
|
+
g.setAttribute('aT', new THREE.BufferAttribute(tpl, 1));
|
|
103
|
+
}
|
|
97
104
|
const K_ON = '#define TRAIL_K aK\nattribute float aK;\n';
|
|
98
105
|
const K_OFF = '#define TRAIL_K 1.0\n';
|
|
99
106
|
function streakShader(glsl, sizePx, spacing, kdef) {
|
|
@@ -102,12 +109,13 @@ function streakShader(glsl, sizePx, spacing, kdef) {
|
|
|
102
109
|
S,
|
|
103
110
|
vertex: /* glsl */ `
|
|
104
111
|
${HEAD}
|
|
112
|
+
attribute float aT;
|
|
105
113
|
attribute vec3 aP;
|
|
106
114
|
attribute vec3 aV;
|
|
107
115
|
${kdef}
|
|
108
116
|
${glsl}
|
|
109
117
|
void main() {
|
|
110
|
-
float f =
|
|
118
|
+
float f = aT; // 0 head .. 1 tail
|
|
111
119
|
vec3 dv = aV * uVelScale * uTrailLength;
|
|
112
120
|
float len = length(dv);
|
|
113
121
|
vec3 p = aP - dv * f;
|
|
@@ -123,6 +131,7 @@ function cometShader(glsl, sizePx, spacing, kdef, SUB) {
|
|
|
123
131
|
const pick = Array.from({ length: SLOTS }, (_, i) => ` ${i === 0 ? 'if' : 'else if'} (i == ${i}) return h${i};`).join('\n');
|
|
124
132
|
return /* glsl */ `
|
|
125
133
|
${HEAD}
|
|
134
|
+
attribute float aT;
|
|
126
135
|
attribute vec3 aP;
|
|
127
136
|
${slots}
|
|
128
137
|
${kdef}
|
|
@@ -142,7 +151,7 @@ vec3 catmull(vec3 a, vec3 b, vec3 c, vec3 d, float t) {
|
|
|
142
151
|
return 0.5 * ((2.0 * b) + (-a + c) * t + (2.0 * a - 5.0 * b + 4.0 * c - d) * t2 + (-a + 3.0 * b - 3.0 * c + d) * t3);
|
|
143
152
|
}
|
|
144
153
|
void main() {
|
|
145
|
-
float s =
|
|
154
|
+
float s = aT; // 0 .. ${SLOTS} along the chain
|
|
146
155
|
int k = int(floor(s));
|
|
147
156
|
float t = s - float(k);
|
|
148
157
|
vec3 p0 = L(k - 1), p1 = L(k), p2 = L(k + 1), p3 = L(k + 2);
|
|
@@ -204,10 +213,10 @@ export function createCpuTrail(mode, opts) {
|
|
|
204
213
|
if (mode === 'streak') {
|
|
205
214
|
const sh = streakShader(glsl, sizePx, spacing, kdef);
|
|
206
215
|
const g = new THREE.InstancedBufferGeometry();
|
|
207
|
-
const tpl = new Float32Array(sh.S
|
|
216
|
+
const tpl = new Float32Array(sh.S);
|
|
208
217
|
for (let i = 0; i < sh.S; i++)
|
|
209
|
-
tpl[i
|
|
210
|
-
g
|
|
218
|
+
tpl[i] = i / (sh.S - 1);
|
|
219
|
+
setTemplate(g, tpl);
|
|
211
220
|
const aP = new THREE.InstancedBufferAttribute(pos, 3).setUsage(THREE.DynamicDrawUsage);
|
|
212
221
|
const aV = new THREE.InstancedBufferAttribute(vel, 3).setUsage(THREE.DynamicDrawUsage);
|
|
213
222
|
g.setAttribute('aP', aP);
|
|
@@ -232,10 +241,10 @@ export function createCpuTrail(mode, opts) {
|
|
|
232
241
|
const g = new THREE.InstancedBufferGeometry();
|
|
233
242
|
const SUBn = opts.sub || SUB; // spline samples per history segment (fast particles need more)
|
|
234
243
|
const M = SLOTS * SUBn + 1;
|
|
235
|
-
const tpl = new Float32Array(M
|
|
244
|
+
const tpl = new Float32Array(M);
|
|
236
245
|
for (let i = 0; i < M; i++)
|
|
237
|
-
tpl[i
|
|
238
|
-
g
|
|
246
|
+
tpl[i] = i / SUBn;
|
|
247
|
+
setTemplate(g, tpl);
|
|
239
248
|
const aP = new THREE.InstancedBufferAttribute(pos, 3).setUsage(THREE.DynamicDrawUsage);
|
|
240
249
|
g.setAttribute('aP', aP);
|
|
241
250
|
const aK = kArr ? new THREE.InstancedBufferAttribute(kArr, 1).setUsage(THREE.DynamicDrawUsage) : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3driseai/3drise-viewer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@3driseai/3drise-common": "^1.0.1",
|
|
42
|
-
"@3driseai/3drise-core": "^1.0.
|
|
42
|
+
"@3driseai/3drise-core": "^1.0.14"
|
|
43
43
|
}
|
|
44
44
|
}
|