@tomorrowevening/hermes 0.1.39 → 0.1.41
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/{ThreeEditor-CTkjs-SY.js → ThreeEditor-jkqfXLb4.js} +16 -16
- package/dist/core/Application.js +77 -0
- package/dist/core/remote/BaseRemote.js +33 -0
- package/dist/core/remote/RemoteTheatre.js +253 -0
- package/dist/core/remote/RemoteThree.js +451 -0
- package/dist/core/types.js +7 -0
- package/dist/editor/Editor.js +12 -0
- package/dist/editor/HermesApp.js +24 -0
- package/dist/editor/ThreeEditor.js +25 -0
- package/dist/editor/components/Draggable.js +40 -0
- package/dist/editor/components/DraggableItem.js +25 -0
- package/dist/editor/components/Dropdown.js +32 -0
- package/dist/editor/components/DropdownItem.js +50 -0
- package/dist/editor/components/NavButton.js +7 -0
- package/dist/editor/components/content.js +4 -0
- package/dist/editor/components/icons/CloseIcon.js +9 -0
- package/dist/editor/components/icons/DragIcon.js +12 -0
- package/dist/editor/multiView/CameraWindow.js +64 -0
- package/dist/editor/multiView/DepthNodeMaterial.js +12 -0
- package/dist/editor/multiView/InfiniteGridHelper.js +31 -0
- package/dist/editor/multiView/InfiniteGridHelperGPU.js +31 -0
- package/dist/editor/multiView/InfiniteGridMaterial.js +137 -0
- package/dist/editor/multiView/InfiniteGridNodeMaterial.js +63 -0
- package/dist/editor/multiView/MultiView.js +890 -0
- package/dist/editor/multiView/Toggle.js +25 -0
- package/dist/editor/multiView/UVMaterial.js +60 -0
- package/dist/editor/multiView/UVNodeMaterial.js +10 -0
- package/dist/editor/sidePanel/Accordion.js +56 -0
- package/dist/editor/sidePanel/ChildObject.js +78 -0
- package/dist/editor/sidePanel/ContainerObject.js +11 -0
- package/dist/editor/sidePanel/DebugData.js +133 -0
- package/dist/editor/sidePanel/SidePanel.js +91 -0
- package/dist/editor/sidePanel/inspector/InspectGrid3.js +82 -0
- package/dist/editor/sidePanel/inspector/InspectGrid4.js +58 -0
- package/dist/editor/sidePanel/inspector/InspectImage.js +100 -0
- package/dist/editor/sidePanel/inspector/InspectNumber.js +76 -0
- package/dist/editor/sidePanel/inspector/InspectVector2.js +154 -0
- package/dist/editor/sidePanel/inspector/Inspector.js +95 -0
- package/dist/editor/sidePanel/inspector/InspectorField.js +128 -0
- package/dist/editor/sidePanel/inspector/InspectorGroup.js +110 -0
- package/dist/editor/sidePanel/inspector/utils/DragNumber.js +27 -0
- package/dist/editor/sidePanel/inspector/utils/InspectAnimation.js +99 -0
- package/dist/editor/sidePanel/inspector/utils/InspectCamera.js +91 -0
- package/dist/editor/sidePanel/inspector/utils/InspectLight.js +85 -0
- package/dist/editor/sidePanel/inspector/utils/InspectMaterial.js +861 -0
- package/dist/editor/sidePanel/inspector/utils/InspectTransform.js +93 -0
- package/dist/editor/sidePanel/utils.js +259 -0
- package/dist/editor/tools/Transform.js +77 -0
- package/dist/editor/tools/splineEditor/Spline.js +348 -0
- package/dist/editor/tools/splineEditor/index.js +193 -0
- package/dist/editor/utils.js +27 -0
- package/dist/hermes.cjs.js +8 -30
- package/dist/{index-BpKOzCuX.js → index-DZmiM5y-.js} +617 -617
- package/dist/index.html +1 -1
- package/dist/index.js +125 -0
- package/dist/utils/ImageSequenceCapturer.js +148 -0
- package/dist/utils/detectSettings.js +46 -0
- package/dist/utils/math.js +68 -0
- package/dist/utils/post.js +206 -0
- package/dist/utils/theatre.js +316 -0
- package/dist/utils/three.js +199 -0
- package/dist/webworkers/EventHandling.js +115 -0
- package/dist/webworkers/ProxyManager.js +76 -0
- package/package.json +13 -7
- package/types/core/remote/RemoteThree.d.ts +10 -1
- package/dist/.vite/manifest.json +0 -12
- package/dist/hermes.es.js +0 -8077
package/dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
|
|
9
9
|
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
|
|
10
10
|
<link rel="manifest" href="/images/site.webmanifest">
|
|
11
|
-
<script type="module" crossorigin src="/index-
|
|
11
|
+
<script type="module" crossorigin src="/index-DZmiM5y-.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/index-C92ji5gy.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { defaultTheatreCallback as t, noop as a } from "./core/types.js";
|
|
2
|
+
import { capitalize as l, colorToHex as p, copyToClipboard as f, isColor as m, randomID as s } from "./editor/utils.js";
|
|
3
|
+
import { detectMaxFrameRate as i, detectSettings as n } from "./utils/detectSettings.js";
|
|
4
|
+
import { ImageSequenceCapturer as u } from "./utils/ImageSequenceCapturer.js";
|
|
5
|
+
import { clamp as M, cubicBezier as b, damp as T, distance as h, getAngle as g, map as C, mix as O, normalize as j, rgbaToHex as I, roundTo as y } from "./utils/math.js";
|
|
6
|
+
import { animateObjectMaterial as G, animateObjectTransform as B, applyObjectMaterial as D, customizeTheatreElements as P, getObjectMaterialObject as S, getObjectMaterialProps as H, useStudio as A } from "./utils/theatre.js";
|
|
7
|
+
import { ExportTexture as R, anchorGeometry as U, anchorGeometryTL as k, createMask as v, dispose as w, disposeMaterial as z, disposeTexture as V, hierarchyUUID as L, orthoCamera as q, parseModelLite as F, renderToTexture as W, resetThreeObjects as J, setMaterialBlendAdd as K, setMaterialBlendMultiply as Q, setMaterialBlendNormal as X, setMaterialBlendScreen as Y, supportsOffscreenCanvas as Z, totalThreeObjects as _, triangle as $, updateCameraOrtho as ee, updateCameraOrtho16x9 as re, useMask as te } from "./utils/three.js";
|
|
8
|
+
import { clearComposerGroups as oe, generateCubemap as le, inspectComposer as pe, inspectComposerPass as fe } from "./utils/post.js";
|
|
9
|
+
import { ElementProxy as se, WebworkerEventHandlers as de } from "./webworkers/EventHandling.js";
|
|
10
|
+
import { ElementProxyReceiver as ne, ProxyManager as xe } from "./webworkers/ProxyManager.js";
|
|
11
|
+
import { default as ce } from "./core/Application.js";
|
|
12
|
+
import { default as be } from "./core/remote/BaseRemote.js";
|
|
13
|
+
import { default as he } from "./core/remote/RemoteTheatre.js";
|
|
14
|
+
import { default as Ce } from "./core/remote/RemoteThree.js";
|
|
15
|
+
import { default as je } from "./editor/components/NavButton.js";
|
|
16
|
+
import { default as ye } from "./editor/components/DraggableItem.js";
|
|
17
|
+
import { default as Ge } from "./editor/components/Draggable.js";
|
|
18
|
+
import { default as De } from "./editor/components/DropdownItem.js";
|
|
19
|
+
import { default as Se } from "./editor/components/Dropdown.js";
|
|
20
|
+
import { default as Ae } from "./editor/sidePanel/SidePanel.js";
|
|
21
|
+
import { default as Re } from "./editor/sidePanel/Accordion.js";
|
|
22
|
+
import { default as ke } from "./editor/sidePanel/ChildObject.js";
|
|
23
|
+
import { default as we } from "./editor/sidePanel/ContainerObject.js";
|
|
24
|
+
import { default as Ve } from "./editor/sidePanel/inspector/Inspector.js";
|
|
25
|
+
import { default as qe } from "./editor/multiView/MultiView.js";
|
|
26
|
+
import { default as We } from "./editor/Editor.js";
|
|
27
|
+
import { default as Ke } from "./editor/ThreeEditor.js";
|
|
28
|
+
import { default as Xe } from "./editor/HermesApp.js";
|
|
29
|
+
import { default as Ze } from "./editor/tools/Transform.js";
|
|
30
|
+
import { default as $e } from "./editor/tools/splineEditor/Spline.js";
|
|
31
|
+
import { default as rr } from "./editor/tools/splineEditor/index.js";
|
|
32
|
+
import { default as ar } from "./editor/multiView/InfiniteGridMaterial.js";
|
|
33
|
+
import { default as lr } from "./editor/multiView/InfiniteGridNodeMaterial.js";
|
|
34
|
+
import { default as fr } from "./editor/multiView/InfiniteGridHelper.js";
|
|
35
|
+
import { default as sr } from "./editor/multiView/InfiniteGridHelperGPU.js";
|
|
36
|
+
import { default as ir } from "./editor/multiView/DepthNodeMaterial.js";
|
|
37
|
+
import { default as xr } from "./editor/multiView/UVMaterial.js";
|
|
38
|
+
import { default as cr } from "./editor/multiView/UVNodeMaterial.js";
|
|
39
|
+
export {
|
|
40
|
+
Re as Accordion,
|
|
41
|
+
ce as Application,
|
|
42
|
+
be as BaseRemote,
|
|
43
|
+
ke as ChildObject,
|
|
44
|
+
we as ContainerObject,
|
|
45
|
+
ir as DepthNodeMaterial,
|
|
46
|
+
Ge as Draggable,
|
|
47
|
+
ye as DraggableItem,
|
|
48
|
+
Se as Dropdown,
|
|
49
|
+
De as DropdownItem,
|
|
50
|
+
We as Editor,
|
|
51
|
+
se as ElementProxy,
|
|
52
|
+
ne as ElementProxyReceiver,
|
|
53
|
+
R as ExportTexture,
|
|
54
|
+
Xe as HermesApp,
|
|
55
|
+
u as ImageSequenceCapturer,
|
|
56
|
+
fr as InfiniteGridHelper,
|
|
57
|
+
sr as InfiniteGridHelperGPU,
|
|
58
|
+
ar as InfiniteGridMaterial,
|
|
59
|
+
lr as InfiniteGridNodeMaterial,
|
|
60
|
+
Ve as Inspector,
|
|
61
|
+
qe as MultiView,
|
|
62
|
+
je as NavButton,
|
|
63
|
+
xe as ProxyManager,
|
|
64
|
+
he as RemoteTheatre,
|
|
65
|
+
Ce as RemoteThree,
|
|
66
|
+
Ae as SidePanel,
|
|
67
|
+
$e as Spline,
|
|
68
|
+
rr as SplineEditor,
|
|
69
|
+
Ke as ThreeEditor,
|
|
70
|
+
Ze as Transform,
|
|
71
|
+
xr as UVMaterial,
|
|
72
|
+
cr as UVNodeMaterial,
|
|
73
|
+
de as WebworkerEventHandlers,
|
|
74
|
+
U as anchorGeometry,
|
|
75
|
+
k as anchorGeometryTL,
|
|
76
|
+
G as animateObjectMaterial,
|
|
77
|
+
B as animateObjectTransform,
|
|
78
|
+
D as applyObjectMaterial,
|
|
79
|
+
l as capitalize,
|
|
80
|
+
M as clamp,
|
|
81
|
+
oe as clearComposerGroups,
|
|
82
|
+
p as colorToHex,
|
|
83
|
+
f as copyToClipboard,
|
|
84
|
+
v as createMask,
|
|
85
|
+
b as cubicBezier,
|
|
86
|
+
P as customizeTheatreElements,
|
|
87
|
+
T as damp,
|
|
88
|
+
t as defaultTheatreCallback,
|
|
89
|
+
i as detectMaxFrameRate,
|
|
90
|
+
n as detectSettings,
|
|
91
|
+
w as dispose,
|
|
92
|
+
z as disposeMaterial,
|
|
93
|
+
V as disposeTexture,
|
|
94
|
+
h as distance,
|
|
95
|
+
le as generateCubemap,
|
|
96
|
+
g as getAngle,
|
|
97
|
+
S as getObjectMaterialObject,
|
|
98
|
+
H as getObjectMaterialProps,
|
|
99
|
+
L as hierarchyUUID,
|
|
100
|
+
pe as inspectComposer,
|
|
101
|
+
fe as inspectComposerPass,
|
|
102
|
+
m as isColor,
|
|
103
|
+
C as map,
|
|
104
|
+
O as mix,
|
|
105
|
+
a as noop,
|
|
106
|
+
j as normalize,
|
|
107
|
+
q as orthoCamera,
|
|
108
|
+
F as parseModelLite,
|
|
109
|
+
s as randomID,
|
|
110
|
+
W as renderToTexture,
|
|
111
|
+
J as resetThreeObjects,
|
|
112
|
+
I as rgbaToHex,
|
|
113
|
+
y as roundTo,
|
|
114
|
+
K as setMaterialBlendAdd,
|
|
115
|
+
Q as setMaterialBlendMultiply,
|
|
116
|
+
X as setMaterialBlendNormal,
|
|
117
|
+
Y as setMaterialBlendScreen,
|
|
118
|
+
Z as supportsOffscreenCanvas,
|
|
119
|
+
_ as totalThreeObjects,
|
|
120
|
+
$ as triangle,
|
|
121
|
+
ee as updateCameraOrtho,
|
|
122
|
+
re as updateCameraOrtho16x9,
|
|
123
|
+
te as useMask,
|
|
124
|
+
A as useStudio
|
|
125
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const c = (
|
|
2
|
+
/* js */
|
|
3
|
+
`
|
|
4
|
+
self.onmessage = async ({ data }) => {
|
|
5
|
+
if (data.type !== 'encode') return;
|
|
6
|
+
const { bitmap, index, format, quality } = data;
|
|
7
|
+
const canvas = new OffscreenCanvas(bitmap.width, bitmap.height);
|
|
8
|
+
const ctx = canvas.getContext('2d');
|
|
9
|
+
ctx.drawImage(bitmap, 0, 0);
|
|
10
|
+
bitmap.close();
|
|
11
|
+
const mime = format === 'jpeg' ? 'image/jpeg' : format === 'webp' ? 'image/webp' : 'image/png';
|
|
12
|
+
const blob = await canvas.convertToBlob({ type: mime, quality });
|
|
13
|
+
self.postMessage({ type: 'encoded', index, blob });
|
|
14
|
+
};
|
|
15
|
+
`
|
|
16
|
+
);
|
|
17
|
+
class d {
|
|
18
|
+
worker;
|
|
19
|
+
source;
|
|
20
|
+
/** Intermediate 2D canvas used for GPU→CPU readback. Works with WebGPU and WebGL. */
|
|
21
|
+
transfer;
|
|
22
|
+
ctx;
|
|
23
|
+
opts;
|
|
24
|
+
_capturing = !1;
|
|
25
|
+
_captured = 0;
|
|
26
|
+
_encoded = 0;
|
|
27
|
+
_pending = 0;
|
|
28
|
+
_lastFrameTime = -1 / 0;
|
|
29
|
+
frames = /* @__PURE__ */ new Map();
|
|
30
|
+
constructor(s, t = {}) {
|
|
31
|
+
this.source = s, this.transfer = document.createElement("canvas"), this.transfer.width = s.width, this.transfer.height = s.height, this.ctx = this.transfer.getContext("2d", { willReadFrequently: !0 }), this.opts = {
|
|
32
|
+
format: t.format ?? "png",
|
|
33
|
+
quality: t.quality ?? 0.92,
|
|
34
|
+
prefix: t.prefix ?? "frame",
|
|
35
|
+
padLength: t.padLength ?? 5,
|
|
36
|
+
maxQueue: t.maxQueue ?? 32,
|
|
37
|
+
fps: t.fps ?? 30,
|
|
38
|
+
onProgress: t.onProgress ?? (() => {
|
|
39
|
+
}),
|
|
40
|
+
onError: t.onError ?? ((e) => console.error("[ImageSequenceCapturer]", e))
|
|
41
|
+
};
|
|
42
|
+
const a = new Blob([c], { type: "application/javascript" }), r = URL.createObjectURL(a);
|
|
43
|
+
this.worker = new Worker(r), URL.revokeObjectURL(r), this.worker.onmessage = ({ data: e }) => {
|
|
44
|
+
e.type === "encoded" && (this.frames.set(e.index, e.blob), this._pending--, this._encoded++, this.opts.onProgress(this._captured, this._encoded));
|
|
45
|
+
}, this.worker.onerror = (e) => this.opts.onError(new Error(e.message));
|
|
46
|
+
}
|
|
47
|
+
get isCapturing() {
|
|
48
|
+
return this._capturing;
|
|
49
|
+
}
|
|
50
|
+
get framesCaptured() {
|
|
51
|
+
return this._captured;
|
|
52
|
+
}
|
|
53
|
+
get framesEncoded() {
|
|
54
|
+
return this._encoded;
|
|
55
|
+
}
|
|
56
|
+
/** True when no frames are waiting to finish encoding. */
|
|
57
|
+
get isIdle() {
|
|
58
|
+
return this._pending === 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Resize the transfer canvas to match the source.
|
|
62
|
+
* Call this if the canvas dimensions change between sessions.
|
|
63
|
+
*/
|
|
64
|
+
resize() {
|
|
65
|
+
this.transfer.width = this.source.width, this.transfer.height = this.source.height;
|
|
66
|
+
}
|
|
67
|
+
/** Begin a new capture session. Clears any previously captured frames. */
|
|
68
|
+
start() {
|
|
69
|
+
this._capturing = !0, this._captured = 0, this._encoded = 0, this._pending = 0, this._lastFrameTime = -1 / 0, this.frames.clear();
|
|
70
|
+
}
|
|
71
|
+
stop() {
|
|
72
|
+
this._capturing = !1;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Capture the current canvas frame and queue it for encoding.
|
|
76
|
+
*
|
|
77
|
+
* **Call this immediately after your render call**, before the next frame begins.
|
|
78
|
+
* This is especially important for WebGPU, where the swap chain texture is
|
|
79
|
+
* only valid until the next `queue.submit()`.
|
|
80
|
+
*
|
|
81
|
+
* Returns `false` if not capturing or the worker queue is full (backpressure).
|
|
82
|
+
*/
|
|
83
|
+
captureFrame() {
|
|
84
|
+
if (!this._capturing || this._pending >= this.opts.maxQueue) return !1;
|
|
85
|
+
const s = performance.now();
|
|
86
|
+
if (s - this._lastFrameTime < 1e3 / this.opts.fps) return !1;
|
|
87
|
+
this._lastFrameTime = s, this.ctx.drawImage(this.source, 0, 0);
|
|
88
|
+
const t = this._captured++;
|
|
89
|
+
return this._pending++, createImageBitmap(this.transfer).then((a) => {
|
|
90
|
+
this.worker.postMessage(
|
|
91
|
+
{ type: "encode", bitmap: a, index: t, format: this.opts.format, quality: this.opts.quality },
|
|
92
|
+
[a]
|
|
93
|
+
// transfer ownership — zero-copy
|
|
94
|
+
);
|
|
95
|
+
}).catch((a) => {
|
|
96
|
+
this._pending--, this.opts.onError(a);
|
|
97
|
+
}), !0;
|
|
98
|
+
}
|
|
99
|
+
/** Resolves once all in-flight frames have finished encoding. */
|
|
100
|
+
flush() {
|
|
101
|
+
return new Promise((s) => {
|
|
102
|
+
const t = () => this._pending === 0 ? s() : setTimeout(t, 16);
|
|
103
|
+
t();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Download all captured frames after waiting for encoding to finish.
|
|
108
|
+
*
|
|
109
|
+
* Prefers the **File System Access API** (`showDirectoryPicker`) so all frames
|
|
110
|
+
* are written directly into a folder the user selects — no zip library needed.
|
|
111
|
+
* Falls back to sequential `<a download>` clicks in browsers that don't support it.
|
|
112
|
+
*/
|
|
113
|
+
async download() {
|
|
114
|
+
await this.flush();
|
|
115
|
+
const s = this.opts.format === "jpeg" ? "jpg" : this.opts.format, a = [...this.frames.entries()].sort(([r], [e]) => r - e).map(([r, e]) => ({
|
|
116
|
+
name: `${this.opts.prefix}_${String(r).padStart(this.opts.padLength, "0")}.${s}`,
|
|
117
|
+
blob: e
|
|
118
|
+
}));
|
|
119
|
+
if ("showDirectoryPicker" in window)
|
|
120
|
+
try {
|
|
121
|
+
const r = await window.showDirectoryPicker({ mode: "readwrite", startIn: "downloads" });
|
|
122
|
+
await Promise.all(
|
|
123
|
+
a.map(async ({ name: e, blob: i }) => {
|
|
124
|
+
const n = await (await r.getFileHandle(e, { create: !0 })).createWritable();
|
|
125
|
+
await n.write(i), await n.close();
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
return;
|
|
129
|
+
} catch (r) {
|
|
130
|
+
if (r.name === "AbortError") return;
|
|
131
|
+
}
|
|
132
|
+
for (const { name: r, blob: e } of a) {
|
|
133
|
+
const i = URL.createObjectURL(e);
|
|
134
|
+
Object.assign(document.createElement("a"), { href: i, download: r }).click(), URL.revokeObjectURL(i), await new Promise((n) => setTimeout(n, 50));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Clear all stored frames without downloading. */
|
|
138
|
+
reset() {
|
|
139
|
+
this._capturing = !1, this._captured = 0, this._encoded = 0, this._pending = 0, this.frames.clear();
|
|
140
|
+
}
|
|
141
|
+
/** Terminate the worker and release all resources. */
|
|
142
|
+
destroy() {
|
|
143
|
+
this.reset(), this.worker.terminate();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export {
|
|
147
|
+
d as ImageSequenceCapturer
|
|
148
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getGPUTier as c } from "detect-gpu";
|
|
2
|
+
function m(o) {
|
|
3
|
+
let n = 0;
|
|
4
|
+
const i = performance.now();
|
|
5
|
+
function e() {
|
|
6
|
+
n++;
|
|
7
|
+
const t = performance.now();
|
|
8
|
+
if (t - i >= 100) {
|
|
9
|
+
const s = n / ((t - i) / 1e3), f = Math.round(s / 30) * 30;
|
|
10
|
+
o(f);
|
|
11
|
+
} else
|
|
12
|
+
requestAnimationFrame(e);
|
|
13
|
+
}
|
|
14
|
+
requestAnimationFrame(e);
|
|
15
|
+
}
|
|
16
|
+
function d(o = !1, n = !1) {
|
|
17
|
+
return new Promise((i) => {
|
|
18
|
+
c().then((e) => {
|
|
19
|
+
let t = !1;
|
|
20
|
+
const s = document.createElement("canvas"), f = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
21
|
+
if (t = "transferControlToOffscreen" in s, f) {
|
|
22
|
+
const a = navigator.userAgent.match(/version\/(\d+)/i);
|
|
23
|
+
t = (a ? parseInt(a[1]) : 0) >= 17;
|
|
24
|
+
}
|
|
25
|
+
const r = {
|
|
26
|
+
dpr: devicePixelRatio,
|
|
27
|
+
fps: 30,
|
|
28
|
+
width: innerWidth,
|
|
29
|
+
height: innerHeight,
|
|
30
|
+
mobile: e.isMobile !== void 0 ? e.isMobile : !1,
|
|
31
|
+
supportOffScreenCanvas: t,
|
|
32
|
+
supportWebGPU: !!navigator.gpu,
|
|
33
|
+
quality: "Low",
|
|
34
|
+
dev: o,
|
|
35
|
+
editor: n
|
|
36
|
+
};
|
|
37
|
+
e.tier === 3 ? r.quality = "High" : e.tier === 2 && (r.quality = "Medium"), m((a) => {
|
|
38
|
+
r.fps = a, i(r);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
m as detectMaxFrameRate,
|
|
45
|
+
d as detectSettings
|
|
46
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function E(n, t, r) {
|
|
2
|
+
return Math.min(t, Math.max(n, r));
|
|
3
|
+
}
|
|
4
|
+
function B(n, t, r) {
|
|
5
|
+
return (r - n) / (t - n);
|
|
6
|
+
}
|
|
7
|
+
function T(n, t, r) {
|
|
8
|
+
return n * (1 - r) + t * r;
|
|
9
|
+
}
|
|
10
|
+
function G(n, t, r, o, c) {
|
|
11
|
+
return T(r, o, B(n, t, c));
|
|
12
|
+
}
|
|
13
|
+
function I(n, t) {
|
|
14
|
+
const r = n - t;
|
|
15
|
+
return Math.sqrt(r * r);
|
|
16
|
+
}
|
|
17
|
+
function L(n, t, r, o) {
|
|
18
|
+
return T(n, t, 1 - Math.exp(-r * o));
|
|
19
|
+
}
|
|
20
|
+
function N(n, t = 1) {
|
|
21
|
+
return Number(n.toFixed(t));
|
|
22
|
+
}
|
|
23
|
+
function j(n, t, r, o) {
|
|
24
|
+
return Math.atan2(o - t, r - n);
|
|
25
|
+
}
|
|
26
|
+
function S(n, t, r, o) {
|
|
27
|
+
return n === t && r === o;
|
|
28
|
+
}
|
|
29
|
+
function q(n, t, r, o) {
|
|
30
|
+
return 1 / (3 * t * n * n + 2 * r * n + o);
|
|
31
|
+
}
|
|
32
|
+
function C(n, t, r, o, c) {
|
|
33
|
+
return t * (n * n * n) + r * (n * n) + o * n + c;
|
|
34
|
+
}
|
|
35
|
+
function D(n, t, r, o, c) {
|
|
36
|
+
const u = n * n;
|
|
37
|
+
return t * (u * n) + r * u + o * n + c;
|
|
38
|
+
}
|
|
39
|
+
function k(n, t, r, o, c) {
|
|
40
|
+
if (n <= 0) return 0;
|
|
41
|
+
if (n >= 1) return 1;
|
|
42
|
+
if (S(t, r, o, c)) return n;
|
|
43
|
+
const u = 0, a = 0, s = t, f = r, x = o, h = c, $ = 1, g = 1, M = $ - 3 * x + 3 * s - u, d = 3 * x - 6 * s + 3 * u, l = 3 * s - 3 * u, y = u, b = g - 3 * h + 3 * f - a, p = 3 * h - 6 * f + 3 * a, H = 3 * f - 3 * a, z = a;
|
|
44
|
+
let i = n;
|
|
45
|
+
for (let F = 0; F < 5; F++) {
|
|
46
|
+
const A = C(i, M, d, l, y);
|
|
47
|
+
let m = q(i, M, d, l);
|
|
48
|
+
m === 1 / 0 && (m = n), i -= (A - n) * m, i = Math.min(Math.max(i, 0), 1);
|
|
49
|
+
}
|
|
50
|
+
return D(i, b, p, H, z);
|
|
51
|
+
}
|
|
52
|
+
const e = (n) => Math.round(Math.min(1, Math.max(0, n)) * 255).toString(16).padStart(2, "0");
|
|
53
|
+
function w({ r: n, g: t, b: r, a: o = 1 }) {
|
|
54
|
+
const c = `#${e(n)}${e(t)}${e(r)}`;
|
|
55
|
+
return o < 1 ? `${c}${e(o)}` : c;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
E as clamp,
|
|
59
|
+
k as cubicBezier,
|
|
60
|
+
L as damp,
|
|
61
|
+
I as distance,
|
|
62
|
+
j as getAngle,
|
|
63
|
+
G as map,
|
|
64
|
+
T as mix,
|
|
65
|
+
B as normalize,
|
|
66
|
+
w as rgbaToHex,
|
|
67
|
+
N as roundTo
|
|
68
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { WebGLRenderTarget as x, RGBAFormat as m } from "three";
|
|
2
|
+
import { ExportTexture as g } from "./three.js";
|
|
3
|
+
let b = [];
|
|
4
|
+
function E(r, n, a = !0) {
|
|
5
|
+
g.renderer = n.renderer;
|
|
6
|
+
const p = [];
|
|
7
|
+
p.push({
|
|
8
|
+
type: "boolean",
|
|
9
|
+
prop: "Enabled",
|
|
10
|
+
value: r.enabled
|
|
11
|
+
});
|
|
12
|
+
let f = (u, e) => {
|
|
13
|
+
console.log("Default Handle Pass:", u, e);
|
|
14
|
+
};
|
|
15
|
+
if (r.name === "EffectPass")
|
|
16
|
+
r.effects.forEach((u) => {
|
|
17
|
+
u.uniforms.size > 0 && u.uniforms.forEach((e, o) => {
|
|
18
|
+
if (o === "map") return;
|
|
19
|
+
const t = `${u.name.replace("Effect", "")} ${o}`;
|
|
20
|
+
if (e.value === null && a)
|
|
21
|
+
p.push({
|
|
22
|
+
prop: o,
|
|
23
|
+
title: t,
|
|
24
|
+
type: "image",
|
|
25
|
+
value: {
|
|
26
|
+
offset: [0, 0],
|
|
27
|
+
repeat: [1, 1],
|
|
28
|
+
src: ""
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
else if (e.value.isTexture && a) {
|
|
32
|
+
const s = e.value, i = g.renderToBlob(s);
|
|
33
|
+
p.push({
|
|
34
|
+
prop: o,
|
|
35
|
+
title: t,
|
|
36
|
+
type: "image",
|
|
37
|
+
value: {
|
|
38
|
+
offset: [s.offset.x, s.offset.y],
|
|
39
|
+
repeat: [s.repeat.x, s.repeat.y],
|
|
40
|
+
src: i
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
} else typeof e.value == "number" ? p.push({
|
|
44
|
+
prop: o,
|
|
45
|
+
title: t,
|
|
46
|
+
type: "number",
|
|
47
|
+
value: e.value,
|
|
48
|
+
step: 0.01
|
|
49
|
+
}) : typeof e.value == "string" ? p.push({
|
|
50
|
+
prop: o,
|
|
51
|
+
title: t,
|
|
52
|
+
type: "string",
|
|
53
|
+
value: e.value
|
|
54
|
+
}) : typeof e.value == "boolean" && p.push({
|
|
55
|
+
prop: o,
|
|
56
|
+
title: t,
|
|
57
|
+
type: "boolean",
|
|
58
|
+
value: e.value
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}), f = (u, e) => {
|
|
62
|
+
r.effects.forEach((o) => {
|
|
63
|
+
o.uniforms.size > 0 && o.uniforms.forEach((t, s) => {
|
|
64
|
+
s === u && (t.value = e);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
else if (r.name === "ShaderPass") {
|
|
69
|
+
const u = r.fullscreenMaterial;
|
|
70
|
+
for (const e in u.uniforms) {
|
|
71
|
+
if (e === "inputBuffer" || e === "map") continue;
|
|
72
|
+
const o = u.uniforms[e], t = `${u.name.replace("Material", "")} ${e}`;
|
|
73
|
+
if (o.value === null && a)
|
|
74
|
+
p.push({
|
|
75
|
+
title: t,
|
|
76
|
+
prop: e,
|
|
77
|
+
type: "image",
|
|
78
|
+
value: {
|
|
79
|
+
offset: [0, 0],
|
|
80
|
+
repeat: [1, 1],
|
|
81
|
+
src: ""
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
else if (o.value.isTexture && a) {
|
|
85
|
+
const s = o.value, i = g.renderToBlob(s);
|
|
86
|
+
p.push({
|
|
87
|
+
title: t,
|
|
88
|
+
prop: e,
|
|
89
|
+
type: "image",
|
|
90
|
+
value: {
|
|
91
|
+
offset: [s.offset.x, s.offset.y],
|
|
92
|
+
repeat: [s.repeat.x, s.repeat.y],
|
|
93
|
+
src: i
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
} else typeof o.value == "number" ? p.push({
|
|
97
|
+
title: t,
|
|
98
|
+
prop: e,
|
|
99
|
+
type: "number",
|
|
100
|
+
value: o.value,
|
|
101
|
+
step: 0.01
|
|
102
|
+
}) : typeof o.value == "string" ? p.push({
|
|
103
|
+
title: t,
|
|
104
|
+
prop: e,
|
|
105
|
+
type: "string",
|
|
106
|
+
value: o.value
|
|
107
|
+
}) : typeof o.value == "boolean" && p.push({
|
|
108
|
+
title: t,
|
|
109
|
+
prop: e,
|
|
110
|
+
type: "boolean",
|
|
111
|
+
value: o.value
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
f = (e, o) => {
|
|
115
|
+
const t = u.uniforms[e];
|
|
116
|
+
t.value = o;
|
|
117
|
+
};
|
|
118
|
+
} else
|
|
119
|
+
return;
|
|
120
|
+
const l = `${r.name}: ${r.scene.name}`;
|
|
121
|
+
n.addGroup({
|
|
122
|
+
title: l,
|
|
123
|
+
items: p,
|
|
124
|
+
onUpdate: (u, e) => {
|
|
125
|
+
u === "Enabled" ? r.enabled = e : f(u, e);
|
|
126
|
+
}
|
|
127
|
+
}), b.push(l);
|
|
128
|
+
}
|
|
129
|
+
function M(r, n) {
|
|
130
|
+
r.passes.forEach((a) => {
|
|
131
|
+
E(a, n);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function B(r) {
|
|
135
|
+
b.forEach((n) => {
|
|
136
|
+
r.removeGroup(n);
|
|
137
|
+
}), b = [];
|
|
138
|
+
}
|
|
139
|
+
function C(r, n, a, p = 1024) {
|
|
140
|
+
return new Promise((f) => {
|
|
141
|
+
const l = n.aspect, u = n.fov, e = n.rotation.clone(), o = a.outputBuffer;
|
|
142
|
+
n.aspect = 1, n.fov = 90, n.updateProjectionMatrix();
|
|
143
|
+
const t = new x(p, p, {
|
|
144
|
+
format: m,
|
|
145
|
+
depthBuffer: !0,
|
|
146
|
+
stencilBuffer: !1
|
|
147
|
+
});
|
|
148
|
+
a.outputBuffer = t, c(r, t, n, "nx", a, p).then(() => {
|
|
149
|
+
c(r, t, n, "ny", a, p).then(() => {
|
|
150
|
+
c(r, t, n, "nz", a, p).then(() => {
|
|
151
|
+
c(r, t, n, "px", a, p).then(() => {
|
|
152
|
+
c(r, t, n, "py", a, p).then(() => {
|
|
153
|
+
c(r, t, n, "pz", a, p).then(() => {
|
|
154
|
+
n.aspect = l, n.fov = u, n.rotation.copy(e), n.updateMatrixWorld(), n.updateProjectionMatrix(), a.outputBuffer = o, t.dispose(), f();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function c(r, n, a, p, f, l) {
|
|
164
|
+
return new Promise((u) => {
|
|
165
|
+
const e = Math.PI / 2;
|
|
166
|
+
switch (p) {
|
|
167
|
+
case "nx":
|
|
168
|
+
a.rotation.set(0, -e, 0);
|
|
169
|
+
break;
|
|
170
|
+
case "ny":
|
|
171
|
+
a.rotation.set(-e, 0, Math.PI);
|
|
172
|
+
break;
|
|
173
|
+
case "nz":
|
|
174
|
+
a.rotation.set(0, 0, 0);
|
|
175
|
+
break;
|
|
176
|
+
case "px":
|
|
177
|
+
a.rotation.set(0, e, 0);
|
|
178
|
+
break;
|
|
179
|
+
case "py":
|
|
180
|
+
a.rotation.set(e, 0, Math.PI);
|
|
181
|
+
break;
|
|
182
|
+
case "pz":
|
|
183
|
+
a.rotation.set(0, Math.PI, 0);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
a.updateMatrixWorld(), f.render();
|
|
187
|
+
const o = new Uint8Array(l * l * 4);
|
|
188
|
+
r.readRenderTargetPixels(n, 0, 0, l, l, o);
|
|
189
|
+
const t = document.createElement("canvas");
|
|
190
|
+
t.width = t.height = l;
|
|
191
|
+
const s = t.getContext("2d"), i = s.createImageData(l, l);
|
|
192
|
+
i.data.set(o), s.putImageData(i, 0, 0);
|
|
193
|
+
const d = document.createElement("canvas");
|
|
194
|
+
d.width = d.height = l;
|
|
195
|
+
const h = d.getContext("2d");
|
|
196
|
+
h.translate(0, l), h.scale(1, -1), h.drawImage(t, 0, 0);
|
|
197
|
+
const y = d.toDataURL("image/png"), v = document.createElement("a");
|
|
198
|
+
v.href = y, v.download = `${a.name}_${p}.png`, document.body.appendChild(v), v.click(), v.remove(), u();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
export {
|
|
202
|
+
B as clearComposerGroups,
|
|
203
|
+
C as generateCubemap,
|
|
204
|
+
M as inspectComposer,
|
|
205
|
+
E as inspectComposerPass
|
|
206
|
+
};
|