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