@tresjs/cientos 0.1.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/LICENSE +21 -0
- package/dist/core/OrbitControls.vue.d.ts +16 -0
- package/dist/env.d.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/trescientos.js +432 -0
- package/dist/trescientos.umd.cjs +8 -0
- package/dist/vite.svg +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-present, (alvarosabu) Alvaro Saburido and Tres contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useLoop, TresState } from '@tresjs/core';
|
|
2
|
+
import { OrbitControls as OrbitControlsImp } from 'three-stdlib';
|
|
3
|
+
import { inject, Ref, unref, watch } from 'vue';
|
|
4
|
+
declare const _sfc_main: import("vue").DefineComponent<{}, {
|
|
5
|
+
controls: OrbitControlsImp;
|
|
6
|
+
tres: Ref<TresState> | undefined;
|
|
7
|
+
useLoop: typeof useLoop;
|
|
8
|
+
UseTresStateSymbol: symbol;
|
|
9
|
+
TresState: any;
|
|
10
|
+
OrbitControlsImp: typeof OrbitControlsImp;
|
|
11
|
+
inject: typeof inject;
|
|
12
|
+
Ref: any;
|
|
13
|
+
unref: typeof unref;
|
|
14
|
+
watch: typeof watch;
|
|
15
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
16
|
+
export default _sfc_main;
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module '*.vue' {
|
|
4
|
+
import type { DefineComponent } from 'vue'
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
|
|
6
|
+
const component: DefineComponent<{}, {}, any>
|
|
7
|
+
export default component
|
|
8
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* name: @tresjs/cientos
|
|
3
|
+
* version: v0.1.0
|
|
4
|
+
* (c) 2022
|
|
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 { defineComponent as ke, inject as Ce, watch as Ye, unref as me } from "vue";
|
|
9
|
+
import { UseTresStateSymbol as _e, useLoop as ze } from "@tresjs/core";
|
|
10
|
+
import { EventDispatcher as He, Vector3 as P, MOUSE as I, TOUCH as N, PerspectiveCamera as R, Quaternion as be, Spherical as ge, Vector2 as f, OrthographicCamera as V } from "three";
|
|
11
|
+
function a(E, h, m) {
|
|
12
|
+
return h in E ? Object.defineProperty(E, h, {
|
|
13
|
+
value: m,
|
|
14
|
+
enumerable: !0,
|
|
15
|
+
configurable: !0,
|
|
16
|
+
writable: !0
|
|
17
|
+
}) : E[h] = m, E;
|
|
18
|
+
}
|
|
19
|
+
const Ee = (E, h) => (E % h + h) % h;
|
|
20
|
+
class Ue extends He {
|
|
21
|
+
constructor(h, m) {
|
|
22
|
+
super(), a(this, "object", void 0), a(this, "domElement", void 0), a(this, "enabled", !0), a(this, "target", new P()), a(this, "minDistance", 0), a(this, "maxDistance", 1 / 0), a(this, "minZoom", 0), a(this, "maxZoom", 1 / 0), a(this, "minPolarAngle", 0), a(this, "maxPolarAngle", Math.PI), a(this, "minAzimuthAngle", -1 / 0), a(this, "maxAzimuthAngle", 1 / 0), a(this, "enableDamping", !1), a(this, "dampingFactor", 0.05), a(this, "enableZoom", !0), a(this, "zoomSpeed", 1), a(this, "enableRotate", !0), a(this, "rotateSpeed", 1), a(this, "enablePan", !0), a(this, "panSpeed", 1), a(this, "screenSpacePanning", !0), a(this, "keyPanSpeed", 7), a(this, "autoRotate", !1), a(this, "autoRotateSpeed", 2), a(this, "reverseOrbit", !1), a(this, "keys", {
|
|
23
|
+
LEFT: "ArrowLeft",
|
|
24
|
+
UP: "ArrowUp",
|
|
25
|
+
RIGHT: "ArrowRight",
|
|
26
|
+
BOTTOM: "ArrowDown"
|
|
27
|
+
}), a(this, "mouseButtons", {
|
|
28
|
+
LEFT: I.ROTATE,
|
|
29
|
+
MIDDLE: I.DOLLY,
|
|
30
|
+
RIGHT: I.PAN
|
|
31
|
+
}), a(this, "touches", {
|
|
32
|
+
ONE: N.ROTATE,
|
|
33
|
+
TWO: N.DOLLY_PAN
|
|
34
|
+
}), a(this, "target0", void 0), a(this, "position0", void 0), a(this, "zoom0", void 0), a(this, "_domElementKeyEvents", null), a(this, "getPolarAngle", void 0), a(this, "getAzimuthalAngle", void 0), a(this, "setPolarAngle", void 0), a(this, "setAzimuthalAngle", void 0), a(this, "getDistance", void 0), a(this, "listenToKeyEvents", void 0), a(this, "saveState", void 0), a(this, "reset", void 0), a(this, "update", void 0), a(this, "connect", void 0), a(this, "dispose", void 0), this.object = h, this.domElement = m, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object instanceof R ? this.object.zoom : 1, this.getPolarAngle = () => c.phi, this.getAzimuthalAngle = () => c.theta, this.setPolarAngle = (t) => {
|
|
35
|
+
let n = Ee(t, 2 * Math.PI), o = c.phi;
|
|
36
|
+
o < 0 && (o += 2 * Math.PI), n < 0 && (n += 2 * Math.PI);
|
|
37
|
+
let i = Math.abs(n - o);
|
|
38
|
+
2 * Math.PI - i < i && (n < o ? n += 2 * Math.PI : o += 2 * Math.PI), d.phi = n - o, e.update();
|
|
39
|
+
}, this.setAzimuthalAngle = (t) => {
|
|
40
|
+
let n = Ee(t, 2 * Math.PI), o = c.theta;
|
|
41
|
+
o < 0 && (o += 2 * Math.PI), n < 0 && (n += 2 * Math.PI);
|
|
42
|
+
let i = Math.abs(n - o);
|
|
43
|
+
2 * Math.PI - i < i && (n < o ? n += 2 * Math.PI : o += 2 * Math.PI), d.theta = n - o, e.update();
|
|
44
|
+
}, this.getDistance = () => e.object.position.distanceTo(e.target), this.listenToKeyEvents = (t) => {
|
|
45
|
+
t.addEventListener("keydown", ue), this._domElementKeyEvents = t;
|
|
46
|
+
}, this.saveState = () => {
|
|
47
|
+
e.target0.copy(e.target), e.position0.copy(e.object.position), e.zoom0 = e.object instanceof R ? e.object.zoom : 1;
|
|
48
|
+
}, this.reset = () => {
|
|
49
|
+
e.target.copy(e.target0), e.object.position.copy(e.position0), e.object instanceof R && (e.object.zoom = e.zoom0, e.object.updateProjectionMatrix()), e.dispatchEvent(S), e.update(), l = r.NONE;
|
|
50
|
+
}, this.update = (() => {
|
|
51
|
+
const t = new P(), n = new be().setFromUnitVectors(h.up, new P(0, 1, 0)), o = n.clone().invert(), i = new P(), u = new be(), p = 2 * Math.PI;
|
|
52
|
+
return function() {
|
|
53
|
+
const fe = e.object.position;
|
|
54
|
+
t.copy(fe).sub(e.target), t.applyQuaternion(n), c.setFromVector3(t), e.autoRotate && l === r.NONE && U(Pe()), e.enableDamping ? (c.theta += d.theta * e.dampingFactor, c.phi += d.phi * e.dampingFactor) : (c.theta += d.theta, c.phi += d.phi);
|
|
55
|
+
let b = e.minAzimuthAngle, g = e.maxAzimuthAngle;
|
|
56
|
+
return isFinite(b) && isFinite(g) && (b < -Math.PI ? b += p : b > Math.PI && (b -= p), g < -Math.PI ? g += p : g > Math.PI && (g -= p), b <= g ? c.theta = Math.max(b, Math.min(g, c.theta)) : c.theta = c.theta > (b + g) / 2 ? Math.max(b, c.theta) : Math.min(g, c.theta)), c.phi = Math.max(e.minPolarAngle, Math.min(e.maxPolarAngle, c.phi)), c.makeSafe(), c.radius *= k, c.radius = Math.max(e.minDistance, Math.min(e.maxDistance, c.radius)), e.enableDamping === !0 ? e.target.addScaledVector(A, e.dampingFactor) : e.target.add(A), t.setFromSpherical(c), t.applyQuaternion(o), fe.copy(e.target).add(t), e.object.lookAt(e.target), e.enableDamping === !0 ? (d.theta *= 1 - e.dampingFactor, d.phi *= 1 - e.dampingFactor, A.multiplyScalar(1 - e.dampingFactor)) : (d.set(0, 0, 0), A.set(0, 0, 0)), k = 1, C || i.distanceToSquared(e.object.position) > q || 8 * (1 - u.dot(e.object.quaternion)) > q ? (e.dispatchEvent(S), i.copy(e.object.position), u.copy(e.object.quaternion), C = !1, !0) : !1;
|
|
57
|
+
};
|
|
58
|
+
})(), this.connect = (t) => {
|
|
59
|
+
t === document && console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'), e.domElement = t, e.domElement.style.touchAction = "none", e.domElement.addEventListener("contextmenu", he), e.domElement.addEventListener("pointerdown", re), e.domElement.addEventListener("pointercancel", le), e.domElement.addEventListener("wheel", ce);
|
|
60
|
+
}, this.dispose = () => {
|
|
61
|
+
var t, n, o, i, u, p;
|
|
62
|
+
(t = e.domElement) === null || t === void 0 || t.removeEventListener("contextmenu", he), (n = e.domElement) === null || n === void 0 || n.removeEventListener("pointerdown", re), (o = e.domElement) === null || o === void 0 || o.removeEventListener("pointercancel", le), (i = e.domElement) === null || i === void 0 || i.removeEventListener("wheel", ce), (u = e.domElement) === null || u === void 0 || u.ownerDocument.removeEventListener("pointermove", F), (p = e.domElement) === null || p === void 0 || p.ownerDocument.removeEventListener("pointerup", X), e._domElementKeyEvents !== null && e._domElementKeyEvents.removeEventListener("keydown", ue);
|
|
63
|
+
};
|
|
64
|
+
const e = this, S = {
|
|
65
|
+
type: "change"
|
|
66
|
+
}, H = {
|
|
67
|
+
type: "start"
|
|
68
|
+
}, W = {
|
|
69
|
+
type: "end"
|
|
70
|
+
}, r = {
|
|
71
|
+
NONE: -1,
|
|
72
|
+
ROTATE: 0,
|
|
73
|
+
DOLLY: 1,
|
|
74
|
+
PAN: 2,
|
|
75
|
+
TOUCH_ROTATE: 3,
|
|
76
|
+
TOUCH_PAN: 4,
|
|
77
|
+
TOUCH_DOLLY_PAN: 5,
|
|
78
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
79
|
+
};
|
|
80
|
+
let l = r.NONE;
|
|
81
|
+
const q = 1e-6, c = new ge(), d = new ge();
|
|
82
|
+
let k = 1;
|
|
83
|
+
const A = new P();
|
|
84
|
+
let C = !1;
|
|
85
|
+
const y = new f(), O = new f(), v = new f(), T = new f(), M = new f(), w = new f(), D = new f(), L = new f(), x = new f(), s = [], Y = {};
|
|
86
|
+
function Pe() {
|
|
87
|
+
return 2 * Math.PI / 60 / 60 * e.autoRotateSpeed;
|
|
88
|
+
}
|
|
89
|
+
function _() {
|
|
90
|
+
return Math.pow(0.95, e.zoomSpeed);
|
|
91
|
+
}
|
|
92
|
+
function U(t) {
|
|
93
|
+
e.reverseOrbit ? d.theta += t : d.theta -= t;
|
|
94
|
+
}
|
|
95
|
+
function G(t) {
|
|
96
|
+
e.reverseOrbit ? d.phi += t : d.phi -= t;
|
|
97
|
+
}
|
|
98
|
+
const B = (() => {
|
|
99
|
+
const t = new P();
|
|
100
|
+
return function(o, i) {
|
|
101
|
+
t.setFromMatrixColumn(i, 0), t.multiplyScalar(-o), A.add(t);
|
|
102
|
+
};
|
|
103
|
+
})(), Q = (() => {
|
|
104
|
+
const t = new P();
|
|
105
|
+
return function(o, i) {
|
|
106
|
+
e.screenSpacePanning === !0 ? t.setFromMatrixColumn(i, 1) : (t.setFromMatrixColumn(i, 0), t.crossVectors(e.object.up, t)), t.multiplyScalar(o), A.add(t);
|
|
107
|
+
};
|
|
108
|
+
})(), j = (() => {
|
|
109
|
+
const t = new P();
|
|
110
|
+
return function(o, i) {
|
|
111
|
+
const u = e.domElement;
|
|
112
|
+
if (u && e.object instanceof R && e.object.isPerspectiveCamera) {
|
|
113
|
+
const p = e.object.position;
|
|
114
|
+
t.copy(p).sub(e.target);
|
|
115
|
+
let z = t.length();
|
|
116
|
+
z *= Math.tan(e.object.fov / 2 * Math.PI / 180), B(2 * o * z / u.clientHeight, e.object.matrix), Q(2 * i * z / u.clientHeight, e.object.matrix);
|
|
117
|
+
} else
|
|
118
|
+
u && e.object instanceof V && e.object.isOrthographicCamera ? (B(o * (e.object.right - e.object.left) / e.object.zoom / u.clientWidth, e.object.matrix), Q(i * (e.object.top - e.object.bottom) / e.object.zoom / u.clientHeight, e.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), e.enablePan = !1);
|
|
119
|
+
};
|
|
120
|
+
})();
|
|
121
|
+
function Z(t) {
|
|
122
|
+
e.object instanceof R && e.object.isPerspectiveCamera ? k /= t : e.object instanceof V && e.object.isOrthographicCamera ? (e.object.zoom = Math.max(e.minZoom, Math.min(e.maxZoom, e.object.zoom * t)), e.object.updateProjectionMatrix(), C = !0) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), e.enableZoom = !1);
|
|
123
|
+
}
|
|
124
|
+
function J(t) {
|
|
125
|
+
e.object instanceof R && e.object.isPerspectiveCamera ? k *= t : e.object instanceof V && e.object.isOrthographicCamera ? (e.object.zoom = Math.max(e.minZoom, Math.min(e.maxZoom, e.object.zoom / t)), e.object.updateProjectionMatrix(), C = !0) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), e.enableZoom = !1);
|
|
126
|
+
}
|
|
127
|
+
function $(t) {
|
|
128
|
+
y.set(t.clientX, t.clientY);
|
|
129
|
+
}
|
|
130
|
+
function ye(t) {
|
|
131
|
+
D.set(t.clientX, t.clientY);
|
|
132
|
+
}
|
|
133
|
+
function ee(t) {
|
|
134
|
+
T.set(t.clientX, t.clientY);
|
|
135
|
+
}
|
|
136
|
+
function Oe(t) {
|
|
137
|
+
O.set(t.clientX, t.clientY), v.subVectors(O, y).multiplyScalar(e.rotateSpeed);
|
|
138
|
+
const n = e.domElement;
|
|
139
|
+
n && (U(2 * Math.PI * v.x / n.clientHeight), G(2 * Math.PI * v.y / n.clientHeight)), y.copy(O), e.update();
|
|
140
|
+
}
|
|
141
|
+
function Te(t) {
|
|
142
|
+
L.set(t.clientX, t.clientY), x.subVectors(L, D), x.y > 0 ? Z(_()) : x.y < 0 && J(_()), D.copy(L), e.update();
|
|
143
|
+
}
|
|
144
|
+
function Me(t) {
|
|
145
|
+
M.set(t.clientX, t.clientY), w.subVectors(M, T).multiplyScalar(e.panSpeed), j(w.x, w.y), T.copy(M), e.update();
|
|
146
|
+
}
|
|
147
|
+
function Ae(t) {
|
|
148
|
+
t.deltaY < 0 ? J(_()) : t.deltaY > 0 && Z(_()), e.update();
|
|
149
|
+
}
|
|
150
|
+
function ve(t) {
|
|
151
|
+
let n = !1;
|
|
152
|
+
switch (t.code) {
|
|
153
|
+
case e.keys.UP:
|
|
154
|
+
j(0, e.keyPanSpeed), n = !0;
|
|
155
|
+
break;
|
|
156
|
+
case e.keys.BOTTOM:
|
|
157
|
+
j(0, -e.keyPanSpeed), n = !0;
|
|
158
|
+
break;
|
|
159
|
+
case e.keys.LEFT:
|
|
160
|
+
j(e.keyPanSpeed, 0), n = !0;
|
|
161
|
+
break;
|
|
162
|
+
case e.keys.RIGHT:
|
|
163
|
+
j(-e.keyPanSpeed, 0), n = !0;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
n && (t.preventDefault(), e.update());
|
|
167
|
+
}
|
|
168
|
+
function te() {
|
|
169
|
+
if (s.length == 1)
|
|
170
|
+
y.set(s[0].pageX, s[0].pageY);
|
|
171
|
+
else {
|
|
172
|
+
const t = 0.5 * (s[0].pageX + s[1].pageX), n = 0.5 * (s[0].pageY + s[1].pageY);
|
|
173
|
+
y.set(t, n);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function ne() {
|
|
177
|
+
if (s.length == 1)
|
|
178
|
+
T.set(s[0].pageX, s[0].pageY);
|
|
179
|
+
else {
|
|
180
|
+
const t = 0.5 * (s[0].pageX + s[1].pageX), n = 0.5 * (s[0].pageY + s[1].pageY);
|
|
181
|
+
T.set(t, n);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function oe() {
|
|
185
|
+
const t = s[0].pageX - s[1].pageX, n = s[0].pageY - s[1].pageY, o = Math.sqrt(t * t + n * n);
|
|
186
|
+
D.set(0, o);
|
|
187
|
+
}
|
|
188
|
+
function we() {
|
|
189
|
+
e.enableZoom && oe(), e.enablePan && ne();
|
|
190
|
+
}
|
|
191
|
+
function De() {
|
|
192
|
+
e.enableZoom && oe(), e.enableRotate && te();
|
|
193
|
+
}
|
|
194
|
+
function ae(t) {
|
|
195
|
+
if (s.length == 1)
|
|
196
|
+
O.set(t.pageX, t.pageY);
|
|
197
|
+
else {
|
|
198
|
+
const o = K(t), i = 0.5 * (t.pageX + o.x), u = 0.5 * (t.pageY + o.y);
|
|
199
|
+
O.set(i, u);
|
|
200
|
+
}
|
|
201
|
+
v.subVectors(O, y).multiplyScalar(e.rotateSpeed);
|
|
202
|
+
const n = e.domElement;
|
|
203
|
+
n && (U(2 * Math.PI * v.x / n.clientHeight), G(2 * Math.PI * v.y / n.clientHeight)), y.copy(O);
|
|
204
|
+
}
|
|
205
|
+
function ie(t) {
|
|
206
|
+
if (s.length == 1)
|
|
207
|
+
M.set(t.pageX, t.pageY);
|
|
208
|
+
else {
|
|
209
|
+
const n = K(t), o = 0.5 * (t.pageX + n.x), i = 0.5 * (t.pageY + n.y);
|
|
210
|
+
M.set(o, i);
|
|
211
|
+
}
|
|
212
|
+
w.subVectors(M, T).multiplyScalar(e.panSpeed), j(w.x, w.y), T.copy(M);
|
|
213
|
+
}
|
|
214
|
+
function se(t) {
|
|
215
|
+
const n = K(t), o = t.pageX - n.x, i = t.pageY - n.y, u = Math.sqrt(o * o + i * i);
|
|
216
|
+
L.set(0, u), x.set(0, Math.pow(L.y / D.y, e.zoomSpeed)), Z(x.y), D.copy(L);
|
|
217
|
+
}
|
|
218
|
+
function Le(t) {
|
|
219
|
+
e.enableZoom && se(t), e.enablePan && ie(t);
|
|
220
|
+
}
|
|
221
|
+
function je(t) {
|
|
222
|
+
e.enableZoom && se(t), e.enableRotate && ae(t);
|
|
223
|
+
}
|
|
224
|
+
function re(t) {
|
|
225
|
+
if (e.enabled !== !1) {
|
|
226
|
+
if (s.length === 0) {
|
|
227
|
+
var n, o;
|
|
228
|
+
(n = e.domElement) === null || n === void 0 || n.ownerDocument.addEventListener("pointermove", F), (o = e.domElement) === null || o === void 0 || o.ownerDocument.addEventListener("pointerup", X);
|
|
229
|
+
}
|
|
230
|
+
xe(t), t.pointerType === "touch" ? Re(t) : Ie(t);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function F(t) {
|
|
234
|
+
e.enabled !== !1 && (t.pointerType === "touch" ? Se(t) : Ne(t));
|
|
235
|
+
}
|
|
236
|
+
function X(t) {
|
|
237
|
+
if (de(t), s.length === 0) {
|
|
238
|
+
var n, o, i;
|
|
239
|
+
(n = e.domElement) === null || n === void 0 || n.releasePointerCapture(t.pointerId), (o = e.domElement) === null || o === void 0 || o.ownerDocument.removeEventListener("pointermove", F), (i = e.domElement) === null || i === void 0 || i.ownerDocument.removeEventListener("pointerup", X);
|
|
240
|
+
}
|
|
241
|
+
e.dispatchEvent(W), l = r.NONE;
|
|
242
|
+
}
|
|
243
|
+
function le(t) {
|
|
244
|
+
de(t);
|
|
245
|
+
}
|
|
246
|
+
function Ie(t) {
|
|
247
|
+
let n;
|
|
248
|
+
switch (t.button) {
|
|
249
|
+
case 0:
|
|
250
|
+
n = e.mouseButtons.LEFT;
|
|
251
|
+
break;
|
|
252
|
+
case 1:
|
|
253
|
+
n = e.mouseButtons.MIDDLE;
|
|
254
|
+
break;
|
|
255
|
+
case 2:
|
|
256
|
+
n = e.mouseButtons.RIGHT;
|
|
257
|
+
break;
|
|
258
|
+
default:
|
|
259
|
+
n = -1;
|
|
260
|
+
}
|
|
261
|
+
switch (n) {
|
|
262
|
+
case I.DOLLY:
|
|
263
|
+
if (e.enableZoom === !1)
|
|
264
|
+
return;
|
|
265
|
+
ye(t), l = r.DOLLY;
|
|
266
|
+
break;
|
|
267
|
+
case I.ROTATE:
|
|
268
|
+
if (t.ctrlKey || t.metaKey || t.shiftKey) {
|
|
269
|
+
if (e.enablePan === !1)
|
|
270
|
+
return;
|
|
271
|
+
ee(t), l = r.PAN;
|
|
272
|
+
} else {
|
|
273
|
+
if (e.enableRotate === !1)
|
|
274
|
+
return;
|
|
275
|
+
$(t), l = r.ROTATE;
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
case I.PAN:
|
|
279
|
+
if (t.ctrlKey || t.metaKey || t.shiftKey) {
|
|
280
|
+
if (e.enableRotate === !1)
|
|
281
|
+
return;
|
|
282
|
+
$(t), l = r.ROTATE;
|
|
283
|
+
} else {
|
|
284
|
+
if (e.enablePan === !1)
|
|
285
|
+
return;
|
|
286
|
+
ee(t), l = r.PAN;
|
|
287
|
+
}
|
|
288
|
+
break;
|
|
289
|
+
default:
|
|
290
|
+
l = r.NONE;
|
|
291
|
+
}
|
|
292
|
+
l !== r.NONE && e.dispatchEvent(H);
|
|
293
|
+
}
|
|
294
|
+
function Ne(t) {
|
|
295
|
+
if (e.enabled !== !1)
|
|
296
|
+
switch (l) {
|
|
297
|
+
case r.ROTATE:
|
|
298
|
+
if (e.enableRotate === !1)
|
|
299
|
+
return;
|
|
300
|
+
Oe(t);
|
|
301
|
+
break;
|
|
302
|
+
case r.DOLLY:
|
|
303
|
+
if (e.enableZoom === !1)
|
|
304
|
+
return;
|
|
305
|
+
Te(t);
|
|
306
|
+
break;
|
|
307
|
+
case r.PAN:
|
|
308
|
+
if (e.enablePan === !1)
|
|
309
|
+
return;
|
|
310
|
+
Me(t);
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function ce(t) {
|
|
315
|
+
e.enabled === !1 || e.enableZoom === !1 || l !== r.NONE && l !== r.ROTATE || (t.preventDefault(), e.dispatchEvent(H), Ae(t), e.dispatchEvent(W));
|
|
316
|
+
}
|
|
317
|
+
function ue(t) {
|
|
318
|
+
e.enabled === !1 || e.enablePan === !1 || ve(t);
|
|
319
|
+
}
|
|
320
|
+
function Re(t) {
|
|
321
|
+
switch (pe(t), s.length) {
|
|
322
|
+
case 1:
|
|
323
|
+
switch (e.touches.ONE) {
|
|
324
|
+
case N.ROTATE:
|
|
325
|
+
if (e.enableRotate === !1)
|
|
326
|
+
return;
|
|
327
|
+
te(), l = r.TOUCH_ROTATE;
|
|
328
|
+
break;
|
|
329
|
+
case N.PAN:
|
|
330
|
+
if (e.enablePan === !1)
|
|
331
|
+
return;
|
|
332
|
+
ne(), l = r.TOUCH_PAN;
|
|
333
|
+
break;
|
|
334
|
+
default:
|
|
335
|
+
l = r.NONE;
|
|
336
|
+
}
|
|
337
|
+
break;
|
|
338
|
+
case 2:
|
|
339
|
+
switch (e.touches.TWO) {
|
|
340
|
+
case N.DOLLY_PAN:
|
|
341
|
+
if (e.enableZoom === !1 && e.enablePan === !1)
|
|
342
|
+
return;
|
|
343
|
+
we(), l = r.TOUCH_DOLLY_PAN;
|
|
344
|
+
break;
|
|
345
|
+
case N.DOLLY_ROTATE:
|
|
346
|
+
if (e.enableZoom === !1 && e.enableRotate === !1)
|
|
347
|
+
return;
|
|
348
|
+
De(), l = r.TOUCH_DOLLY_ROTATE;
|
|
349
|
+
break;
|
|
350
|
+
default:
|
|
351
|
+
l = r.NONE;
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
default:
|
|
355
|
+
l = r.NONE;
|
|
356
|
+
}
|
|
357
|
+
l !== r.NONE && e.dispatchEvent(H);
|
|
358
|
+
}
|
|
359
|
+
function Se(t) {
|
|
360
|
+
switch (pe(t), l) {
|
|
361
|
+
case r.TOUCH_ROTATE:
|
|
362
|
+
if (e.enableRotate === !1)
|
|
363
|
+
return;
|
|
364
|
+
ae(t), e.update();
|
|
365
|
+
break;
|
|
366
|
+
case r.TOUCH_PAN:
|
|
367
|
+
if (e.enablePan === !1)
|
|
368
|
+
return;
|
|
369
|
+
ie(t), e.update();
|
|
370
|
+
break;
|
|
371
|
+
case r.TOUCH_DOLLY_PAN:
|
|
372
|
+
if (e.enableZoom === !1 && e.enablePan === !1)
|
|
373
|
+
return;
|
|
374
|
+
Le(t), e.update();
|
|
375
|
+
break;
|
|
376
|
+
case r.TOUCH_DOLLY_ROTATE:
|
|
377
|
+
if (e.enableZoom === !1 && e.enableRotate === !1)
|
|
378
|
+
return;
|
|
379
|
+
je(t), e.update();
|
|
380
|
+
break;
|
|
381
|
+
default:
|
|
382
|
+
l = r.NONE;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function he(t) {
|
|
386
|
+
e.enabled !== !1 && t.preventDefault();
|
|
387
|
+
}
|
|
388
|
+
function xe(t) {
|
|
389
|
+
s.push(t);
|
|
390
|
+
}
|
|
391
|
+
function de(t) {
|
|
392
|
+
delete Y[t.pointerId];
|
|
393
|
+
for (let n = 0; n < s.length; n++)
|
|
394
|
+
if (s[n].pointerId == t.pointerId) {
|
|
395
|
+
s.splice(n, 1);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function pe(t) {
|
|
400
|
+
let n = Y[t.pointerId];
|
|
401
|
+
n === void 0 && (n = new f(), Y[t.pointerId] = n), n.set(t.pageX, t.pageY);
|
|
402
|
+
}
|
|
403
|
+
function K(t) {
|
|
404
|
+
const n = t.pointerId === s[0].pointerId ? s[1] : s[0];
|
|
405
|
+
return Y[n.pointerId];
|
|
406
|
+
}
|
|
407
|
+
m !== void 0 && this.connect(m), this.update();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const Ke = /* @__PURE__ */ ke({
|
|
411
|
+
__name: "OrbitControls",
|
|
412
|
+
setup(E) {
|
|
413
|
+
let h;
|
|
414
|
+
const m = Ce(_e);
|
|
415
|
+
return Ye(
|
|
416
|
+
() => m,
|
|
417
|
+
() => {
|
|
418
|
+
const { camera: e, renderer: S } = m;
|
|
419
|
+
e && me(S) && (h = new Ue(e, me(S).domElement), h.enableDamping = !0, ze(() => {
|
|
420
|
+
h && h.update();
|
|
421
|
+
}));
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
deep: !0
|
|
425
|
+
}
|
|
426
|
+
), () => {
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
export {
|
|
431
|
+
Ke as OrbitControls
|
|
432
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* name: @tresjs/cientos
|
|
3
|
+
* version: v0.1.0
|
|
4
|
+
* (c) 2022
|
|
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
|
+
(function(m,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("vue"),require("@tresjs/core"),require("three")):typeof define=="function"&&define.amd?define(["exports","vue","@tresjs/core","three"],b):(m=typeof globalThis<"u"?globalThis:m||self,b(m.trescientos={},m.Vue,m.core,m.Three))})(this,function(m,b,K,n){"use strict";function i(O,d,g){return d in O?Object.defineProperty(O,d,{value:g,enumerable:!0,configurable:!0,writable:!0}):O[d]=g,O}const q=(O,d)=>(O%d+d)%d;class fe extends n.EventDispatcher{constructor(d,g){super(),i(this,"object",void 0),i(this,"domElement",void 0),i(this,"enabled",!0),i(this,"target",new n.Vector3),i(this,"minDistance",0),i(this,"maxDistance",1/0),i(this,"minZoom",0),i(this,"maxZoom",1/0),i(this,"minPolarAngle",0),i(this,"maxPolarAngle",Math.PI),i(this,"minAzimuthAngle",-1/0),i(this,"maxAzimuthAngle",1/0),i(this,"enableDamping",!1),i(this,"dampingFactor",.05),i(this,"enableZoom",!0),i(this,"zoomSpeed",1),i(this,"enableRotate",!0),i(this,"rotateSpeed",1),i(this,"enablePan",!0),i(this,"panSpeed",1),i(this,"screenSpacePanning",!0),i(this,"keyPanSpeed",7),i(this,"autoRotate",!1),i(this,"autoRotateSpeed",2),i(this,"reverseOrbit",!1),i(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),i(this,"mouseButtons",{LEFT:n.MOUSE.ROTATE,MIDDLE:n.MOUSE.DOLLY,RIGHT:n.MOUSE.PAN}),i(this,"touches",{ONE:n.TOUCH.ROTATE,TWO:n.TOUCH.DOLLY_PAN}),i(this,"target0",void 0),i(this,"position0",void 0),i(this,"zoom0",void 0),i(this,"_domElementKeyEvents",null),i(this,"getPolarAngle",void 0),i(this,"getAzimuthalAngle",void 0),i(this,"setPolarAngle",void 0),i(this,"setAzimuthalAngle",void 0),i(this,"getDistance",void 0),i(this,"listenToKeyEvents",void 0),i(this,"saveState",void 0),i(this,"reset",void 0),i(this,"update",void 0),i(this,"connect",void 0),i(this,"dispose",void 0),this.object=d,this.domElement=g,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object instanceof n.PerspectiveCamera?this.object.zoom:1,this.getPolarAngle=()=>u.phi,this.getAzimuthalAngle=()=>u.theta,this.setPolarAngle=t=>{let o=q(t,2*Math.PI),a=u.phi;a<0&&(a+=2*Math.PI),o<0&&(o+=2*Math.PI);let s=Math.abs(o-a);2*Math.PI-s<s&&(o<a?o+=2*Math.PI:a+=2*Math.PI),p.phi=o-a,e.update()},this.setAzimuthalAngle=t=>{let o=q(t,2*Math.PI),a=u.theta;a<0&&(a+=2*Math.PI),o<0&&(o+=2*Math.PI);let s=Math.abs(o-a);2*Math.PI-s<s&&(o<a?o+=2*Math.PI:a+=2*Math.PI),p.theta=o-a,e.update()},this.getDistance=()=>e.object.position.distanceTo(e.target),this.listenToKeyEvents=t=>{t.addEventListener("keydown",le),this._domElementKeyEvents=t},this.saveState=()=>{e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object instanceof n.PerspectiveCamera?e.object.zoom:1},this.reset=()=>{e.target.copy(e.target0),e.object.position.copy(e.position0),e.object instanceof n.PerspectiveCamera&&(e.object.zoom=e.zoom0,e.object.updateProjectionMatrix()),e.dispatchEvent(C),e.update(),l=c.NONE},this.update=(()=>{const t=new n.Vector3,o=new n.Quaternion().setFromUnitVectors(d.up,new n.Vector3(0,1,0)),a=o.clone().invert(),s=new n.Vector3,h=new n.Quaternion,f=2*Math.PI;return function(){const pe=e.object.position;t.copy(pe).sub(e.target),t.applyQuaternion(o),u.setFromVector3(t),e.autoRotate&&l===c.NONE&&z(be()),e.enableDamping?(u.theta+=p.theta*e.dampingFactor,u.phi+=p.phi*e.dampingFactor):(u.theta+=p.theta,u.phi+=p.phi);let P=e.minAzimuthAngle,y=e.maxAzimuthAngle;return isFinite(P)&&isFinite(y)&&(P<-Math.PI?P+=f:P>Math.PI&&(P-=f),y<-Math.PI?y+=f:y>Math.PI&&(y-=f),P<=y?u.theta=Math.max(P,Math.min(y,u.theta)):u.theta=u.theta>(P+y)/2?Math.max(P,u.theta):Math.min(y,u.theta)),u.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,u.phi)),u.makeSafe(),u.radius*=x,u.radius=Math.max(e.minDistance,Math.min(e.maxDistance,u.radius)),e.enableDamping===!0?e.target.addScaledVector(D,e.dampingFactor):e.target.add(D),t.setFromSpherical(u),t.applyQuaternion(a),pe.copy(e.target).add(t),e.object.lookAt(e.target),e.enableDamping===!0?(p.theta*=1-e.dampingFactor,p.phi*=1-e.dampingFactor,D.multiplyScalar(1-e.dampingFactor)):(p.set(0,0,0),D.set(0,0,0)),x=1,k||s.distanceToSquared(e.object.position)>G||8*(1-h.dot(e.object.quaternion))>G?(e.dispatchEvent(C),s.copy(e.object.position),h.copy(e.object.quaternion),k=!1,!0):!1}})(),this.connect=t=>{t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),e.domElement=t,e.domElement.style.touchAction="none",e.domElement.addEventListener("contextmenu",ue),e.domElement.addEventListener("pointerdown",se),e.domElement.addEventListener("pointercancel",re),e.domElement.addEventListener("wheel",ce)},this.dispose=()=>{var t,o,a,s,h,f;(t=e.domElement)===null||t===void 0||t.removeEventListener("contextmenu",ue),(o=e.domElement)===null||o===void 0||o.removeEventListener("pointerdown",se),(a=e.domElement)===null||a===void 0||a.removeEventListener("pointercancel",re),(s=e.domElement)===null||s===void 0||s.removeEventListener("wheel",ce),(h=e.domElement)===null||h===void 0||h.ownerDocument.removeEventListener("pointermove",F),(f=e.domElement)===null||f===void 0||f.ownerDocument.removeEventListener("pointerup",X),e._domElementKeyEvents!==null&&e._domElementKeyEvents.removeEventListener("keydown",le)};const e=this,C={type:"change"},V={type:"start"},W={type:"end"},c={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=c.NONE;const G=1e-6,u=new n.Spherical,p=new n.Spherical;let x=1;const D=new n.Vector3;let k=!1;const M=new n.Vector2,v=new n.Vector2,j=new n.Vector2,A=new n.Vector2,w=new n.Vector2,L=new n.Vector2,S=new n.Vector2,I=new n.Vector2,T=new n.Vector2,r=[],Y={};function be(){return 2*Math.PI/60/60*e.autoRotateSpeed}function U(){return Math.pow(.95,e.zoomSpeed)}function z(t){e.reverseOrbit?p.theta+=t:p.theta-=t}function B(t){e.reverseOrbit?p.phi+=t:p.phi-=t}const Q=(()=>{const t=new n.Vector3;return function(a,s){t.setFromMatrixColumn(s,0),t.multiplyScalar(-a),D.add(t)}})(),R=(()=>{const t=new n.Vector3;return function(a,s){e.screenSpacePanning===!0?t.setFromMatrixColumn(s,1):(t.setFromMatrixColumn(s,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(a),D.add(t)}})(),N=(()=>{const t=new n.Vector3;return function(a,s){const h=e.domElement;if(h&&e.object instanceof n.PerspectiveCamera&&e.object.isPerspectiveCamera){const f=e.object.position;t.copy(f).sub(e.target);let _=t.length();_*=Math.tan(e.object.fov/2*Math.PI/180),Q(2*a*_/h.clientHeight,e.object.matrix),R(2*s*_/h.clientHeight,e.object.matrix)}else h&&e.object instanceof n.OrthographicCamera&&e.object.isOrthographicCamera?(Q(a*(e.object.right-e.object.left)/e.object.zoom/h.clientWidth,e.object.matrix),R(s*(e.object.top-e.object.bottom)/e.object.zoom/h.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}})();function Z(t){e.object instanceof n.PerspectiveCamera&&e.object.isPerspectiveCamera?x/=t:e.object instanceof n.OrthographicCamera&&e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom*t)),e.object.updateProjectionMatrix(),k=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function J(t){e.object instanceof n.PerspectiveCamera&&e.object.isPerspectiveCamera?x*=t:e.object instanceof n.OrthographicCamera&&e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/t)),e.object.updateProjectionMatrix(),k=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function $(t){M.set(t.clientX,t.clientY)}function ge(t){S.set(t.clientX,t.clientY)}function H(t){A.set(t.clientX,t.clientY)}function Pe(t){v.set(t.clientX,t.clientY),j.subVectors(v,M).multiplyScalar(e.rotateSpeed);const o=e.domElement;o&&(z(2*Math.PI*j.x/o.clientHeight),B(2*Math.PI*j.y/o.clientHeight)),M.copy(v),e.update()}function ye(t){I.set(t.clientX,t.clientY),T.subVectors(I,S),T.y>0?Z(U()):T.y<0&&J(U()),S.copy(I),e.update()}function Oe(t){w.set(t.clientX,t.clientY),L.subVectors(w,A).multiplyScalar(e.panSpeed),N(L.x,L.y),A.copy(w),e.update()}function Me(t){t.deltaY<0?J(U()):t.deltaY>0&&Z(U()),e.update()}function ve(t){let o=!1;switch(t.code){case e.keys.UP:N(0,e.keyPanSpeed),o=!0;break;case e.keys.BOTTOM:N(0,-e.keyPanSpeed),o=!0;break;case e.keys.LEFT:N(e.keyPanSpeed,0),o=!0;break;case e.keys.RIGHT:N(-e.keyPanSpeed,0),o=!0;break}o&&(t.preventDefault(),e.update())}function ee(){if(r.length==1)M.set(r[0].pageX,r[0].pageY);else{const t=.5*(r[0].pageX+r[1].pageX),o=.5*(r[0].pageY+r[1].pageY);M.set(t,o)}}function te(){if(r.length==1)A.set(r[0].pageX,r[0].pageY);else{const t=.5*(r[0].pageX+r[1].pageX),o=.5*(r[0].pageY+r[1].pageY);A.set(t,o)}}function oe(){const t=r[0].pageX-r[1].pageX,o=r[0].pageY-r[1].pageY,a=Math.sqrt(t*t+o*o);S.set(0,a)}function Ae(){e.enableZoom&&oe(),e.enablePan&&te()}function we(){e.enableZoom&&oe(),e.enableRotate&&ee()}function ne(t){if(r.length==1)v.set(t.pageX,t.pageY);else{const a=E(t),s=.5*(t.pageX+a.x),h=.5*(t.pageY+a.y);v.set(s,h)}j.subVectors(v,M).multiplyScalar(e.rotateSpeed);const o=e.domElement;o&&(z(2*Math.PI*j.x/o.clientHeight),B(2*Math.PI*j.y/o.clientHeight)),M.copy(v)}function ae(t){if(r.length==1)w.set(t.pageX,t.pageY);else{const o=E(t),a=.5*(t.pageX+o.x),s=.5*(t.pageY+o.y);w.set(a,s)}L.subVectors(w,A).multiplyScalar(e.panSpeed),N(L.x,L.y),A.copy(w)}function ie(t){const o=E(t),a=t.pageX-o.x,s=t.pageY-o.y,h=Math.sqrt(a*a+s*s);I.set(0,h),T.set(0,Math.pow(I.y/S.y,e.zoomSpeed)),Z(T.y),S.copy(I)}function De(t){e.enableZoom&&ie(t),e.enablePan&&ae(t)}function je(t){e.enableZoom&&ie(t),e.enableRotate&&ne(t)}function se(t){if(e.enabled!==!1){if(r.length===0){var o,a;(o=e.domElement)===null||o===void 0||o.ownerDocument.addEventListener("pointermove",F),(a=e.domElement)===null||a===void 0||a.ownerDocument.addEventListener("pointerup",X)}Ce(t),t.pointerType==="touch"?Ie(t):Le(t)}}function F(t){e.enabled!==!1&&(t.pointerType==="touch"?Ne(t):Se(t))}function X(t){if(he(t),r.length===0){var o,a,s;(o=e.domElement)===null||o===void 0||o.releasePointerCapture(t.pointerId),(a=e.domElement)===null||a===void 0||a.ownerDocument.removeEventListener("pointermove",F),(s=e.domElement)===null||s===void 0||s.ownerDocument.removeEventListener("pointerup",X)}e.dispatchEvent(W),l=c.NONE}function re(t){he(t)}function Le(t){let o;switch(t.button){case 0:o=e.mouseButtons.LEFT;break;case 1:o=e.mouseButtons.MIDDLE;break;case 2:o=e.mouseButtons.RIGHT;break;default:o=-1}switch(o){case n.MOUSE.DOLLY:if(e.enableZoom===!1)return;ge(t),l=c.DOLLY;break;case n.MOUSE.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enablePan===!1)return;H(t),l=c.PAN}else{if(e.enableRotate===!1)return;$(t),l=c.ROTATE}break;case n.MOUSE.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enableRotate===!1)return;$(t),l=c.ROTATE}else{if(e.enablePan===!1)return;H(t),l=c.PAN}break;default:l=c.NONE}l!==c.NONE&&e.dispatchEvent(V)}function Se(t){if(e.enabled!==!1)switch(l){case c.ROTATE:if(e.enableRotate===!1)return;Pe(t);break;case c.DOLLY:if(e.enableZoom===!1)return;ye(t);break;case c.PAN:if(e.enablePan===!1)return;Oe(t);break}}function ce(t){e.enabled===!1||e.enableZoom===!1||l!==c.NONE&&l!==c.ROTATE||(t.preventDefault(),e.dispatchEvent(V),Me(t),e.dispatchEvent(W))}function le(t){e.enabled===!1||e.enablePan===!1||ve(t)}function Ie(t){switch(de(t),r.length){case 1:switch(e.touches.ONE){case n.TOUCH.ROTATE:if(e.enableRotate===!1)return;ee(),l=c.TOUCH_ROTATE;break;case n.TOUCH.PAN:if(e.enablePan===!1)return;te(),l=c.TOUCH_PAN;break;default:l=c.NONE}break;case 2:switch(e.touches.TWO){case n.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ae(),l=c.TOUCH_DOLLY_PAN;break;case n.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;we(),l=c.TOUCH_DOLLY_ROTATE;break;default:l=c.NONE}break;default:l=c.NONE}l!==c.NONE&&e.dispatchEvent(V)}function Ne(t){switch(de(t),l){case c.TOUCH_ROTATE:if(e.enableRotate===!1)return;ne(t),e.update();break;case c.TOUCH_PAN:if(e.enablePan===!1)return;ae(t),e.update();break;case c.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;De(t),e.update();break;case c.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;je(t),e.update();break;default:l=c.NONE}}function ue(t){e.enabled!==!1&&t.preventDefault()}function Ce(t){r.push(t)}function he(t){delete Y[t.pointerId];for(let o=0;o<r.length;o++)if(r[o].pointerId==t.pointerId){r.splice(o,1);return}}function de(t){let o=Y[t.pointerId];o===void 0&&(o=new n.Vector2,Y[t.pointerId]=o),o.set(t.pageX,t.pageY)}function E(t){const o=t.pointerId===r[0].pointerId?r[1]:r[0];return Y[o.pointerId]}g!==void 0&&this.connect(g),this.update()}}const me=b.defineComponent({__name:"OrbitControls",setup(O){let d;const g=b.inject(K.UseTresStateSymbol);return b.watch(()=>g,()=>{const{camera:e,renderer:C}=g;e&&b.unref(C)&&(d=new fe(e,b.unref(C).domElement),d.enableDamping=!0,K.useLoop(()=>{d&&d.update()}))},{deep:!0}),()=>{}}});m.OrbitControls=me,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tresjs/cientos",
|
|
3
|
+
"description": "Collection of useful helpers and fully functional, ready-made abstractions for Tres",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "./dist/trescientos.umd.cjs",
|
|
12
|
+
"module": "./dist/trescientos.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/trescientos.js",
|
|
17
|
+
"require": "./dist/trescientos.umd.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./styles": "./dist/style.css",
|
|
20
|
+
"./*": "./dist/trescientos.js"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"vue",
|
|
27
|
+
"3d",
|
|
28
|
+
"threejs",
|
|
29
|
+
"three",
|
|
30
|
+
"threejs-vue"
|
|
31
|
+
],
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@tresjs/core": "^0.2.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@vitejs/plugin-vue": "^3.2.0",
|
|
37
|
+
"typescript": "^4.6.4",
|
|
38
|
+
"vite": "^3.2.3",
|
|
39
|
+
"kolorist": "^1.6.0",
|
|
40
|
+
"pathe": "^0.3.9",
|
|
41
|
+
"rollup-plugin-analyzer": "^4.0.0",
|
|
42
|
+
"rollup-plugin-visualizer": "^5.8.3",
|
|
43
|
+
"three-stdlib": "^2.17.3",
|
|
44
|
+
"vite-plugin-banner": "^0.5.0",
|
|
45
|
+
"vite-plugin-dts": "^1.6.6"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"three": "latest",
|
|
49
|
+
"vue": "^3.2.41"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"dev": "vite",
|
|
53
|
+
"build": "tsc && vite build",
|
|
54
|
+
"preview": "vite preview",
|
|
55
|
+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue"
|
|
56
|
+
}
|
|
57
|
+
}
|