@tresjs/core 1.1.0 → 1.2.1
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/core/useInstanceCreator/index.d.ts +1 -1
- package/dist/env.d.ts +1 -0
- package/dist/tres.js +246 -226
- package/dist/tres.umd.cjs +2 -2
- package/dist/types/index.d.ts +11 -0
- package/package.json +2 -2
- package/dist/favicon-16x16.png +0 -0
- package/dist/favicon-32x32.png +0 -0
- package/dist/favicon-dark.svg +0 -6
- package/dist/favicon.ico +0 -0
- package/dist/favicon.svg +0 -5
- package/dist/logo-dark.svg +0 -5
- package/dist/logo.svg +0 -5
- package/dist/models/AkuAku.gltf +0 -1177
- package/dist/pwa-192x192.png +0 -0
- package/dist/pwa-512x512.png +0 -0
- package/dist/safari-pinned-tab.svg +0 -5
- package/dist/textures/stylized-leaves-material/Stylized_Leaves_002_ambientOcclusion.jpg +0 -0
- package/dist/textures/stylized-leaves-material/Stylized_Leaves_002_basecolor.jpg +0 -0
- package/dist/textures/stylized-leaves-material/Stylized_Leaves_002_height.png +0 -0
- package/dist/textures/stylized-leaves-material/Stylized_Leaves_002_normal.jpg +0 -0
- package/dist/textures/stylized-leaves-material/Stylized_Leaves_002_roughness.jpg +0 -0
- package/dist/vite.svg +0 -1
|
@@ -3,5 +3,5 @@ import { TresCatalogue, TresInstance, TresVNode } from '../../types';
|
|
|
3
3
|
export declare function useInstanceCreator(prefix: string): {
|
|
4
4
|
createComponentInstances: (catalogue: Ref<TresCatalogue>) => (string | import("vue").DefineComponent<{}, () => void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>)[][];
|
|
5
5
|
processProps: (props: Record<string, any>, instance: TresInstance) => void;
|
|
6
|
-
createInstanceFromVNode: (vnode: TresVNode
|
|
6
|
+
createInstanceFromVNode: (vnode: TresVNode) => TresInstance | TresInstance[] | undefined;
|
|
7
7
|
};
|
package/dist/env.d.ts
CHANGED
package/dist/tres.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v1.
|
|
3
|
+
* version: v1.2.0
|
|
4
4
|
* (c) 2022
|
|
5
5
|
* description: Declarative ThreeJS using Vue Components
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
import { computed as
|
|
9
|
-
import { useWindowSize as
|
|
10
|
-
import * as
|
|
11
|
-
import { PerspectiveCamera as
|
|
12
|
-
var
|
|
8
|
+
import { computed as j, watch as O, inject as T, ref as P, defineComponent as k, shallowRef as N, reactive as ve, toRefs as ye, provide as b, onBeforeUnmount as Ce, h as q } from "vue";
|
|
9
|
+
import { useWindowSize as ee, createEventHook as W, useRafFn as Se, useElementSize as Me, useDevicePixelRatio as xe, unrefElement as z, resolveUnref as y } from "@vueuse/core";
|
|
10
|
+
import * as Q from "three";
|
|
11
|
+
import { PerspectiveCamera as A, OrthographicCamera as te, Color as D, Vector3 as Ee, Clock as Te, Scene as Pe, LoadingManager as Re, TextureLoader as Le, PCFShadowMap as Oe, LinearEncoding as be, NoToneMapping as Ae, WebGLRenderer as $e } from "three";
|
|
12
|
+
var Be = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Be || {});
|
|
13
13
|
const M = {
|
|
14
14
|
cameras: []
|
|
15
|
-
},
|
|
16
|
-
let
|
|
17
|
-
function
|
|
18
|
-
const { width: e, height: t } =
|
|
19
|
-
function
|
|
20
|
-
if (
|
|
21
|
-
const { near:
|
|
15
|
+
}, Ie = 45;
|
|
16
|
+
let C;
|
|
17
|
+
function ne() {
|
|
18
|
+
const { width: e, height: t } = ee(), { setState: n } = le();
|
|
19
|
+
function o(r = "Perspective", u) {
|
|
20
|
+
if (r === "Perspective") {
|
|
21
|
+
const { near: s, far: c, fov: p } = u || {
|
|
22
22
|
near: 0.1,
|
|
23
23
|
far: 1e3,
|
|
24
|
-
fov:
|
|
24
|
+
fov: Ie
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
C = new A(p, i.value, s, c), M.cameras.push(C);
|
|
27
27
|
} else {
|
|
28
|
-
const { left:
|
|
28
|
+
const { left: s, right: c, top: p, bottom: m, near: g, far: v } = u || {
|
|
29
29
|
left: -100,
|
|
30
30
|
right: 100,
|
|
31
31
|
top: 100,
|
|
@@ -33,289 +33,306 @@ function ee() {
|
|
|
33
33
|
near: 0.1,
|
|
34
34
|
far: 1e3
|
|
35
35
|
};
|
|
36
|
-
|
|
36
|
+
C = new te(s, c, p, m, g, v), M.cameras.push(C);
|
|
37
37
|
}
|
|
38
|
-
return M.cameras.push(
|
|
38
|
+
return M.cameras.push(C), C;
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const i = j(() => e.value / t.value), l = j(() => M.cameras[0]);
|
|
41
41
|
function f() {
|
|
42
|
-
l.value instanceof
|
|
42
|
+
l.value instanceof A && (l.value.aspect = i.value), l.value.updateProjectionMatrix();
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const u =
|
|
46
|
-
|
|
44
|
+
function a(r) {
|
|
45
|
+
const u = T("camera");
|
|
46
|
+
r && u && (u.value = r, n("camera", u.value)), M.cameras.push(r), r instanceof A && (r.aspect = i.value), r.updateProjectionMatrix();
|
|
47
47
|
}
|
|
48
|
-
return
|
|
48
|
+
return O(i, f), {
|
|
49
49
|
activeCamera: l,
|
|
50
|
-
createCamera:
|
|
50
|
+
createCamera: o,
|
|
51
51
|
updateCamera: f,
|
|
52
|
-
pushCamera:
|
|
52
|
+
pushCamera: a
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
!b && e && (b = e);
|
|
60
|
-
const { createComponentInstances: r } = te(t);
|
|
61
|
-
return {
|
|
62
|
-
extend: (s) => {
|
|
63
|
-
L.value = Object.assign(L.value, s), r(S(s)).forEach(([f, c]) => {
|
|
64
|
-
b.component(f, c);
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
catalogue: L
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const F = (e) => typeof e < "u", ze = (e) => typeof e == "function", R = (e) => !!e && e.constructor === Array;
|
|
71
|
-
function De(e) {
|
|
72
|
-
return typeof e == "number" ? [e, e, e] : e instanceof xe ? [e.x, e.y, e.z] : e;
|
|
73
|
-
}
|
|
74
|
-
function K(e) {
|
|
75
|
-
return e instanceof $ ? e : Array.isArray(e) ? new $(...e) : new $(e);
|
|
76
|
-
}
|
|
77
|
-
const q = "[TresJS \u25B2 \u25A0 \u25CF] ";
|
|
78
|
-
function U() {
|
|
79
|
-
function e(a, s) {
|
|
80
|
-
console.error(`${q} ${a}`, s || "");
|
|
55
|
+
const X = "[TresJS \u25B2 \u25A0 \u25CF] ";
|
|
56
|
+
function B() {
|
|
57
|
+
function e(o, i) {
|
|
58
|
+
console.error(`${X} ${o}`, i || "");
|
|
81
59
|
}
|
|
82
|
-
function t(
|
|
83
|
-
console.warn(`${
|
|
60
|
+
function t(o) {
|
|
61
|
+
console.warn(`${X} ${o}`);
|
|
84
62
|
}
|
|
85
|
-
function
|
|
63
|
+
function n(o, i) {
|
|
86
64
|
}
|
|
87
65
|
return {
|
|
88
66
|
logError: e,
|
|
89
67
|
logWarning: t,
|
|
90
|
-
logMessage:
|
|
68
|
+
logMessage: n
|
|
91
69
|
};
|
|
92
70
|
}
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
71
|
+
const E = P({ ...Q, uuid: Q.MathUtils.generateUUID() });
|
|
72
|
+
delete E.value.Scene;
|
|
73
|
+
let x;
|
|
74
|
+
function re(e, t = "Tres") {
|
|
75
|
+
const { logMessage: n, logError: o } = B();
|
|
76
|
+
!x && e && (x = e);
|
|
77
|
+
const { createComponentInstances: i } = ae(t);
|
|
78
|
+
return {
|
|
79
|
+
extend: (f) => {
|
|
80
|
+
if (!f) {
|
|
81
|
+
o("No objects provided to extend catalogue");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
E.value = Object.assign(E.value, f);
|
|
85
|
+
const a = i(P(f));
|
|
86
|
+
n("Adding objects to catalogue", { objects: f, catalogue: E.value.uuid }), x && a.forEach(([r, u]) => {
|
|
87
|
+
x._context.components[r] || x.component(r, u);
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
catalogue: E
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const U = (e) => typeof e < "u", _e = (e) => typeof e == "function", $ = (e) => !!e && e.constructor === Array;
|
|
94
|
+
function Fe(e) {
|
|
95
|
+
return typeof e == "number" ? [e, e, e] : e instanceof Ee ? [e.x, e.y, e.z] : e;
|
|
96
|
+
}
|
|
97
|
+
function Y(e) {
|
|
98
|
+
return e instanceof D ? e : Array.isArray(e) ? new D(...e) : new D(e);
|
|
99
|
+
}
|
|
100
|
+
const ze = ["rotation", "scale", "position"];
|
|
101
|
+
function ae(e) {
|
|
102
|
+
const { logMessage: t, logError: n } = B();
|
|
103
|
+
function o(a, r) {
|
|
104
|
+
!U(a) || !U(r) || Object.entries(a).forEach(([u, s]) => {
|
|
105
|
+
const c = u.replace(/(-\w)/g, (p) => p[1].toUpperCase());
|
|
106
|
+
if (!(c === "args" || s === void 0)) {
|
|
107
|
+
ze.includes(c) && s && (s = Fe(s)), a.ref && (a.ref = r);
|
|
101
108
|
try {
|
|
102
|
-
if (
|
|
103
|
-
|
|
109
|
+
if (r[c] && U(r[c].set))
|
|
110
|
+
r[c].set(...$(s) ? s : [s]);
|
|
104
111
|
else {
|
|
105
|
-
if (
|
|
106
|
-
|
|
112
|
+
if (s === "" && (s = !0), _e(r[c])) {
|
|
113
|
+
r[c](...$(s) ? s : [s]);
|
|
107
114
|
return;
|
|
108
115
|
}
|
|
109
|
-
|
|
116
|
+
r[c] = s;
|
|
110
117
|
}
|
|
111
118
|
} catch (p) {
|
|
112
|
-
|
|
119
|
+
n(`There was an error setting ${c} property`, p);
|
|
113
120
|
}
|
|
114
121
|
}
|
|
115
122
|
});
|
|
116
123
|
}
|
|
117
|
-
function
|
|
118
|
-
var
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
function i(a) {
|
|
125
|
+
var s;
|
|
126
|
+
const r = /^Symbol\(Fragment\)$/g, u = /^Symbol\(Text\)$/g;
|
|
127
|
+
if (r.test(a.type.toString()))
|
|
128
|
+
return a.children.map((c) => i(c));
|
|
129
|
+
if (u.test(a.type.toString()))
|
|
130
|
+
return;
|
|
131
|
+
{
|
|
132
|
+
const c = a.type.name.replace(e, ""), { catalogue: p } = re(), m = T("catalogue") || p;
|
|
133
|
+
let g;
|
|
134
|
+
return m && ((s = a == null ? void 0 : a.props) != null && s.args ? m != null && m.value[c] ? g = new m.value[c](...a.props.args) : n(`There is no ${c} in the catalogue`, m == null ? void 0 : m.value.uuid) : g = new m.value[c]()), a != null && a.props && o(a.props, g), g;
|
|
135
|
+
}
|
|
122
136
|
}
|
|
123
|
-
function l(
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
126
|
-
return new
|
|
137
|
+
function l(a, r, u) {
|
|
138
|
+
if (u.default && (u == null ? void 0 : u.default())) {
|
|
139
|
+
const s = u.default().map((c) => i(c));
|
|
140
|
+
return new a(...s.flat().filter(Boolean));
|
|
127
141
|
} else
|
|
128
|
-
return
|
|
142
|
+
return r.args ? new a(...r.args) : new a();
|
|
129
143
|
}
|
|
130
|
-
function f(
|
|
131
|
-
return Object.entries(
|
|
132
|
-
var
|
|
133
|
-
return (
|
|
134
|
-
}).map(([
|
|
135
|
-
const
|
|
136
|
-
name:
|
|
137
|
-
setup(p, { slots:
|
|
138
|
-
const { scene:
|
|
139
|
-
|
|
144
|
+
function f(a) {
|
|
145
|
+
return Object.entries(a.value).filter(([r, u]) => {
|
|
146
|
+
var s, c;
|
|
147
|
+
return (c = (s = u == null ? void 0 : u.prototype) == null ? void 0 : s.constructor) == null ? void 0 : c.toString().includes("class");
|
|
148
|
+
}).map(([r, u]) => {
|
|
149
|
+
const s = `${e}${r}`, c = k({
|
|
150
|
+
name: s,
|
|
151
|
+
setup(p, { slots: m, attrs: g, ...v }) {
|
|
152
|
+
const { scene: R } = ue(), w = T("local-scene") || R, S = T("catalogue"), { pushCamera: I } = ne();
|
|
153
|
+
let h = l(u, g, m);
|
|
154
|
+
return o(g, h), (h instanceof A || h instanceof te) && I(h), h.isObject3D && (w == null || w.value.add(h)), v.expose(h), t(s, {
|
|
155
|
+
sceneuuid: w == null ? void 0 : w.value.uuid,
|
|
156
|
+
catalogue: S == null ? void 0 : S.value.uuid,
|
|
140
157
|
props: p,
|
|
141
|
-
slots:
|
|
158
|
+
slots: m.default ? m.default() : void 0,
|
|
142
159
|
attrs: g,
|
|
143
|
-
ctx:
|
|
144
|
-
scene:
|
|
160
|
+
ctx: v,
|
|
161
|
+
scene: w
|
|
145
162
|
}), () => {
|
|
146
163
|
};
|
|
147
164
|
}
|
|
148
165
|
});
|
|
149
|
-
return [
|
|
166
|
+
return [s, c];
|
|
150
167
|
});
|
|
151
168
|
}
|
|
152
169
|
return {
|
|
153
170
|
createComponentInstances: f,
|
|
154
|
-
processProps:
|
|
155
|
-
createInstanceFromVNode:
|
|
171
|
+
processProps: o,
|
|
172
|
+
createInstanceFromVNode: i
|
|
156
173
|
};
|
|
157
174
|
}
|
|
158
|
-
const
|
|
175
|
+
const oe = W(), se = W(), ie = W(), Z = new Te(), { pause: De, resume: Ue, isActive: Ve } = Se(
|
|
159
176
|
() => {
|
|
160
|
-
const e =
|
|
161
|
-
|
|
177
|
+
const e = Z.getElapsedTime(), t = Z.getDelta();
|
|
178
|
+
oe.trigger({ delta: t, elapsed: e }), se.trigger({ delta: t, elapsed: e }), ie.trigger({ delta: t, elapsed: e });
|
|
162
179
|
},
|
|
163
180
|
{ immediate: !1 }
|
|
164
181
|
);
|
|
165
|
-
function
|
|
182
|
+
function ce() {
|
|
166
183
|
return {
|
|
167
|
-
onBeforeLoop:
|
|
168
|
-
onLoop:
|
|
169
|
-
onAfterLoop:
|
|
170
|
-
pause:
|
|
171
|
-
resume:
|
|
172
|
-
isActive:
|
|
184
|
+
onBeforeLoop: oe.on,
|
|
185
|
+
onLoop: se.on,
|
|
186
|
+
onAfterLoop: ie.on,
|
|
187
|
+
pause: De,
|
|
188
|
+
resume: Ue,
|
|
189
|
+
isActive: Ve
|
|
173
190
|
};
|
|
174
191
|
}
|
|
175
|
-
const
|
|
176
|
-
function
|
|
192
|
+
const je = N(new Pe());
|
|
193
|
+
function ue() {
|
|
177
194
|
return {
|
|
178
|
-
scene:
|
|
195
|
+
scene: je
|
|
179
196
|
};
|
|
180
197
|
}
|
|
181
|
-
function
|
|
198
|
+
function ke(e) {
|
|
182
199
|
const t = { nodes: {}, materials: {} };
|
|
183
|
-
return e && e.traverse((
|
|
184
|
-
|
|
200
|
+
return e && e.traverse((n) => {
|
|
201
|
+
n.name && (t.nodes[n.name] = n), n.material && !t.materials[n.material.name] && (t.materials[n.material.name] = n.material);
|
|
185
202
|
}), t;
|
|
186
203
|
}
|
|
187
|
-
async function Qe(e, t,
|
|
188
|
-
const { logError: l } =
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
(u) => new Promise((
|
|
204
|
+
async function Qe(e, t, n, o, i) {
|
|
205
|
+
const { logError: l } = B(), f = new e();
|
|
206
|
+
i && i(f), n && n(e);
|
|
207
|
+
const r = (Array.isArray(t) ? t : [t]).map(
|
|
208
|
+
(u) => new Promise((s, c) => {
|
|
192
209
|
f.load(
|
|
193
210
|
u,
|
|
194
211
|
(p) => {
|
|
195
|
-
p.scene && Object.assign(p,
|
|
212
|
+
p.scene && Object.assign(p, ke(p.scene)), s(p);
|
|
196
213
|
},
|
|
197
|
-
|
|
198
|
-
(p) =>
|
|
214
|
+
o,
|
|
215
|
+
(p) => c(l("[useLoader] - Failed to load resource", p))
|
|
199
216
|
);
|
|
200
217
|
})
|
|
201
218
|
);
|
|
202
|
-
return
|
|
219
|
+
return $(t) ? await Promise.all(r) : await r[0];
|
|
203
220
|
}
|
|
204
221
|
async function Xe(e) {
|
|
205
|
-
const t = new
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
(
|
|
222
|
+
const t = new Re(), n = new Le(t), o = (i) => new Promise((l, f) => {
|
|
223
|
+
n.load(
|
|
224
|
+
i,
|
|
225
|
+
(a) => l(a),
|
|
209
226
|
() => null,
|
|
210
227
|
() => {
|
|
211
228
|
f(new Error("[useTextures] - Failed to load texture"));
|
|
212
229
|
}
|
|
213
230
|
);
|
|
214
231
|
});
|
|
215
|
-
if (
|
|
216
|
-
const
|
|
217
|
-
return e.length > 1 ?
|
|
232
|
+
if ($(e)) {
|
|
233
|
+
const i = await Promise.all(e.map((l) => o(l)));
|
|
234
|
+
return e.length > 1 ? i : i[0];
|
|
218
235
|
} else {
|
|
219
|
-
const { map:
|
|
236
|
+
const { map: i, displacementMap: l, normalMap: f, roughnessMap: a, metalnessMap: r, aoMap: u } = e;
|
|
220
237
|
return {
|
|
221
|
-
map:
|
|
222
|
-
displacementMap: l ? await
|
|
223
|
-
normalMap: f ? await
|
|
224
|
-
roughnessMap:
|
|
225
|
-
metalnessMap:
|
|
226
|
-
aoMap: u ? await
|
|
238
|
+
map: i ? await o(i) : null,
|
|
239
|
+
displacementMap: l ? await o(l) : null,
|
|
240
|
+
normalMap: f ? await o(f) : null,
|
|
241
|
+
roughnessMap: a ? await o(a) : null,
|
|
242
|
+
metalnessMap: r ? await o(r) : null,
|
|
243
|
+
aoMap: u ? await o(u) : null
|
|
227
244
|
};
|
|
228
245
|
}
|
|
229
246
|
}
|
|
230
|
-
const
|
|
231
|
-
function
|
|
232
|
-
function e(
|
|
233
|
-
return
|
|
247
|
+
const L = ve({});
|
|
248
|
+
function le() {
|
|
249
|
+
function e(n) {
|
|
250
|
+
return L[n];
|
|
234
251
|
}
|
|
235
|
-
function t(
|
|
236
|
-
|
|
252
|
+
function t(n, o) {
|
|
253
|
+
L[n] = o;
|
|
237
254
|
}
|
|
238
255
|
return {
|
|
239
|
-
state:
|
|
240
|
-
...
|
|
256
|
+
state: L,
|
|
257
|
+
...ye(L),
|
|
241
258
|
getState: e,
|
|
242
259
|
setState: t
|
|
243
260
|
};
|
|
244
261
|
}
|
|
245
|
-
const
|
|
246
|
-
function
|
|
262
|
+
const d = N(), V = P(!1);
|
|
263
|
+
function Ne(e, t, n) {
|
|
247
264
|
const {
|
|
248
|
-
alpha:
|
|
249
|
-
antialias:
|
|
265
|
+
alpha: o = !1,
|
|
266
|
+
antialias: i,
|
|
250
267
|
depth: l,
|
|
251
268
|
logarithmicDepthBuffer: f,
|
|
252
|
-
failIfMajorPerformanceCaveat:
|
|
253
|
-
precision:
|
|
269
|
+
failIfMajorPerformanceCaveat: a,
|
|
270
|
+
precision: r,
|
|
254
271
|
premultipliedAlpha: u,
|
|
255
|
-
stencil:
|
|
256
|
-
shadows:
|
|
272
|
+
stencil: s,
|
|
273
|
+
shadows: c = !1,
|
|
257
274
|
shadowMapType: p = Oe,
|
|
258
|
-
physicallyCorrectLights:
|
|
259
|
-
outputEncoding: g =
|
|
260
|
-
toneMapping:
|
|
261
|
-
toneMappingExposure:
|
|
262
|
-
context:
|
|
263
|
-
powerPreference:
|
|
264
|
-
preserveDrawingBuffer:
|
|
265
|
-
clearColor:
|
|
266
|
-
windowSize:
|
|
267
|
-
} =
|
|
268
|
-
!
|
|
269
|
-
},
|
|
270
|
-
!
|
|
271
|
-
},
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
275
|
+
physicallyCorrectLights: m = !1,
|
|
276
|
+
outputEncoding: g = be,
|
|
277
|
+
toneMapping: v = Ae,
|
|
278
|
+
toneMappingExposure: R = 1,
|
|
279
|
+
context: w = void 0,
|
|
280
|
+
powerPreference: S = "default",
|
|
281
|
+
preserveDrawingBuffer: I = !1,
|
|
282
|
+
clearColor: h = Y("#000000"),
|
|
283
|
+
windowSize: fe = !1
|
|
284
|
+
} = n, { width: _, height: F } = fe ? ee() : Me(t), { pixelRatio: H } = xe(), { pause: pe, resume: me } = ce(), de = j(() => _.value / F.value), G = () => {
|
|
285
|
+
!d.value || (d.value.setSize(_.value, F.value), d.value.setPixelRatio(Math.min(H.value, 2)));
|
|
286
|
+
}, J = () => {
|
|
287
|
+
!d.value || (d.value.shadowMap.enabled = y(c), d.value.outputEncoding = y(g), d.value.shadowMap.type = y(p), d.value.physicallyCorrectLights = y(m), d.value.toneMapping = y(v), d.value.toneMappingExposure = y(R), d.value.setClearColor(Y(y(h))));
|
|
288
|
+
}, ge = () => {
|
|
289
|
+
const K = z(e);
|
|
290
|
+
if (d.value || !K)
|
|
274
291
|
return;
|
|
275
|
-
|
|
276
|
-
canvas:
|
|
277
|
-
alpha:
|
|
278
|
-
antialias:
|
|
279
|
-
context:
|
|
292
|
+
d.value = new $e({
|
|
293
|
+
canvas: K,
|
|
294
|
+
alpha: o,
|
|
295
|
+
antialias: i,
|
|
296
|
+
context: w,
|
|
280
297
|
depth: l,
|
|
281
|
-
failIfMajorPerformanceCaveat:
|
|
298
|
+
failIfMajorPerformanceCaveat: a,
|
|
282
299
|
logarithmicDepthBuffer: f,
|
|
283
|
-
powerPreference:
|
|
284
|
-
precision:
|
|
285
|
-
stencil:
|
|
286
|
-
preserveDrawingBuffer:
|
|
300
|
+
powerPreference: S,
|
|
301
|
+
precision: r,
|
|
302
|
+
stencil: s,
|
|
303
|
+
preserveDrawingBuffer: I,
|
|
287
304
|
premultipliedAlpha: u
|
|
288
305
|
});
|
|
289
|
-
const { setState:
|
|
290
|
-
|
|
291
|
-
},
|
|
292
|
-
!
|
|
306
|
+
const { setState: we } = le();
|
|
307
|
+
we("renderer", d.value), J(), G(), me(), V.value = !0;
|
|
308
|
+
}, he = () => {
|
|
309
|
+
!d.value || (d.value.dispose(), d.value = void 0, V.value = !1, pe());
|
|
293
310
|
};
|
|
294
|
-
return
|
|
311
|
+
return O([_, F, H], G), O(
|
|
295
312
|
() => [
|
|
296
|
-
|
|
313
|
+
c,
|
|
297
314
|
p,
|
|
298
315
|
g,
|
|
299
|
-
|
|
300
|
-
w,
|
|
316
|
+
m,
|
|
301
317
|
v,
|
|
302
|
-
|
|
318
|
+
R,
|
|
319
|
+
h
|
|
303
320
|
],
|
|
304
|
-
|
|
305
|
-
),
|
|
321
|
+
J
|
|
322
|
+
), O(
|
|
306
323
|
() => [e, t],
|
|
307
324
|
() => {
|
|
308
|
-
|
|
325
|
+
z(e) && z(t) && ge();
|
|
309
326
|
},
|
|
310
327
|
{ immediate: !0, deep: !0 }
|
|
311
328
|
), {
|
|
312
|
-
renderer:
|
|
313
|
-
isReady:
|
|
314
|
-
dispose:
|
|
315
|
-
aspectRatio:
|
|
329
|
+
renderer: d,
|
|
330
|
+
isReady: V,
|
|
331
|
+
dispose: he,
|
|
332
|
+
aspectRatio: de
|
|
316
333
|
};
|
|
317
334
|
}
|
|
318
|
-
const
|
|
335
|
+
const We = k({
|
|
319
336
|
name: "TresCanvas",
|
|
320
337
|
props: {
|
|
321
338
|
shadows: Boolean,
|
|
@@ -330,14 +347,14 @@ const He = _({
|
|
|
330
347
|
clearColor: String,
|
|
331
348
|
windowSize: Boolean
|
|
332
349
|
},
|
|
333
|
-
setup(e, { slots: t, attrs:
|
|
334
|
-
const { logError:
|
|
335
|
-
return
|
|
336
|
-
var
|
|
337
|
-
return (
|
|
338
|
-
}) &&
|
|
350
|
+
setup(e, { slots: t, attrs: n }) {
|
|
351
|
+
const { logError: o } = B(), i = P(), l = P(), { renderer: f, dispose: a, aspectRatio: r } = Ne(i, l, e), u = N();
|
|
352
|
+
return b("camera", u), b("renderer", f), b("aspect-ratio", r), t.default && !t.default().some((s) => s.type.name === "Scene") && o("TresCanvas must contain a Scene component."), t.default && !t.default().some((s) => {
|
|
353
|
+
var c;
|
|
354
|
+
return (c = s.type.name) == null ? void 0 : c.includes("Camera");
|
|
355
|
+
}) && o("Scene must contain a Camera component."), Ce(() => a()), () => {
|
|
339
356
|
if (t.default)
|
|
340
|
-
return
|
|
357
|
+
return q(
|
|
341
358
|
"div",
|
|
342
359
|
{
|
|
343
360
|
ref: l,
|
|
@@ -345,12 +362,12 @@ const He = _({
|
|
|
345
362
|
position: "relative",
|
|
346
363
|
width: "100%",
|
|
347
364
|
height: "100vh",
|
|
348
|
-
...
|
|
365
|
+
...n.style
|
|
349
366
|
}
|
|
350
367
|
},
|
|
351
368
|
[
|
|
352
|
-
|
|
353
|
-
ref:
|
|
369
|
+
q("canvas", {
|
|
370
|
+
ref: i,
|
|
354
371
|
style: { width: "100%", height: "100%", position: "absolute", top: 0, left: 0 }
|
|
355
372
|
}),
|
|
356
373
|
t.default()
|
|
@@ -358,41 +375,44 @@ const He = _({
|
|
|
358
375
|
);
|
|
359
376
|
};
|
|
360
377
|
}
|
|
361
|
-
}),
|
|
378
|
+
}), He = k({
|
|
362
379
|
name: "Scene",
|
|
363
380
|
setup(e, { slots: t }) {
|
|
364
|
-
const { scene:
|
|
365
|
-
return
|
|
366
|
-
(
|
|
381
|
+
const { scene: n } = ue(), o = T("renderer"), { activeCamera: i } = ne(), { onLoop: l } = ce();
|
|
382
|
+
return b("local-scene", n), l(() => {
|
|
383
|
+
(o == null ? void 0 : o.value) && (i == null ? void 0 : i.value) && (n == null ? void 0 : n.value) && o.value.render(n == null ? void 0 : n.value, i.value);
|
|
367
384
|
}), () => {
|
|
368
385
|
if (t.default)
|
|
369
386
|
return t.default();
|
|
370
387
|
};
|
|
371
388
|
}
|
|
372
|
-
}), Ye = Symbol("UseTresState"), Ze = {
|
|
389
|
+
}), Ye = Symbol("UseTresState"), Ge = "1.2.0", Ze = {
|
|
373
390
|
install(e, t) {
|
|
374
|
-
const
|
|
375
|
-
e.component(`${
|
|
376
|
-
const { catalogue:
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
})
|
|
391
|
+
const n = (t == null ? void 0 : t.prefix) || "Tres";
|
|
392
|
+
e.component(`${n}Canvas`, We), e.component(`${n}Scene`, He);
|
|
393
|
+
const { catalogue: o, extend: i } = re(e, n);
|
|
394
|
+
e.provide("catalogue", o), e.provide("extend", i);
|
|
395
|
+
const { createComponentInstances: l } = ae(n);
|
|
396
|
+
l(o).forEach(([a, r]) => {
|
|
397
|
+
e.component(a, r);
|
|
398
|
+
}), window.__TRES__ = {
|
|
399
|
+
app: e,
|
|
400
|
+
version: Ge
|
|
401
|
+
};
|
|
382
402
|
}
|
|
383
403
|
};
|
|
384
404
|
export {
|
|
385
|
-
|
|
405
|
+
Be as CameraType,
|
|
386
406
|
Ye as UseTresStateSymbol,
|
|
387
407
|
Ze as default,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
408
|
+
ke as trasverseObjects,
|
|
409
|
+
ne as useCamera,
|
|
410
|
+
re as useCatalogue,
|
|
411
|
+
ae as useInstanceCreator,
|
|
392
412
|
Qe as useLoader,
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
413
|
+
ce as useRenderLoop,
|
|
414
|
+
Ne as useRenderer,
|
|
415
|
+
ue as useScene,
|
|
396
416
|
Xe as useTexture,
|
|
397
|
-
|
|
417
|
+
le as useTres
|
|
398
418
|
};
|