@gui-chat-plugin/present3d 0.0.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/vue.js ADDED
@@ -0,0 +1,794 @@
1
+ import { c as N, d as Z, s as ft, p as bt } from "./toThreeJS-EXFMlO7B.js";
2
+ import { a as he, e as le } from "./toThreeJS-EXFMlO7B.js";
3
+ import { defineComponent as tt, ref as R, computed as et, onMounted as it, nextTick as q, onUnmounted as st, watch as O, createElementBlock as K, openBlock as H, createElementVNode as _, createCommentVNode as gt, toDisplayString as k, createTextVNode as j, withDirectives as yt, vModelText as wt } from "vue";
4
+ import * as g from "three";
5
+ import { Controls as Pt, Vector3 as E, MOUSE as C, TOUCH as x, Quaternion as B, Spherical as Q, Vector2 as P, Ray as Et, Plane as St, MathUtils as Dt } from "three";
6
+ const $ = { type: "change" }, F = { type: "start" }, ot = { type: "end" }, z = new Et(), J = new St(), Tt = Math.cos(70 * Dt.DEG2RAD), d = new E(), f = 2 * Math.PI, l = {
7
+ NONE: -1,
8
+ ROTATE: 0,
9
+ DOLLY: 1,
10
+ PAN: 2,
11
+ TOUCH_ROTATE: 3,
12
+ TOUCH_PAN: 4,
13
+ TOUCH_DOLLY_PAN: 5,
14
+ TOUCH_DOLLY_ROTATE: 6
15
+ }, Y = 1e-6;
16
+ class vt extends Pt {
17
+ constructor(t, e = null) {
18
+ super(t, e), this.state = l.NONE, this.enabled = !0, this.target = new E(), this.cursor = new E(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: C.ROTATE, MIDDLE: C.DOLLY, RIGHT: C.PAN }, this.touches = { ONE: x.ROTATE, TWO: x.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new E(), this._lastQuaternion = new B(), this._lastTargetPosition = new E(), this._quat = new B().setFromUnitVectors(t.up, new E(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new Q(), this._sphericalDelta = new Q(), this._scale = 1, this._panOffset = new E(), this._rotateStart = new P(), this._rotateEnd = new P(), this._rotateDelta = new P(), this._panStart = new P(), this._panEnd = new P(), this._panDelta = new P(), this._dollyStart = new P(), this._dollyEnd = new P(), this._dollyDelta = new P(), this._dollyDirection = new E(), this._mouse = new P(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = Rt.bind(this), this._onPointerDown = Mt.bind(this), this._onPointerUp = Ot.bind(this), this._onContextMenu = zt.bind(this), this._onMouseWheel = Lt.bind(this), this._onKeyDown = At.bind(this), this._onTouchStart = kt.bind(this), this._onTouchMove = jt.bind(this), this._onMouseDown = xt.bind(this), this._onMouseMove = Ct.bind(this), this._interceptControlDown = Nt.bind(this), this._interceptControlUp = It.bind(this), this.domElement !== null && this.connect(), this.update();
19
+ }
20
+ connect() {
21
+ this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), this.domElement.style.touchAction = "none";
22
+ }
23
+ disconnect() {
24
+ this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = "auto";
25
+ }
26
+ dispose() {
27
+ this.disconnect();
28
+ }
29
+ getPolarAngle() {
30
+ return this._spherical.phi;
31
+ }
32
+ getAzimuthalAngle() {
33
+ return this._spherical.theta;
34
+ }
35
+ getDistance() {
36
+ return this.object.position.distanceTo(this.target);
37
+ }
38
+ listenToKeyEvents(t) {
39
+ t.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = t;
40
+ }
41
+ stopListenToKeyEvents() {
42
+ this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
43
+ }
44
+ saveState() {
45
+ this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
46
+ }
47
+ reset() {
48
+ this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent($), this.update(), this.state = l.NONE;
49
+ }
50
+ update(t = null) {
51
+ const e = this.object.position;
52
+ d.copy(e).sub(this.target), d.applyQuaternion(this._quat), this._spherical.setFromVector3(d), this.autoRotate && this.state === l.NONE && this._rotateLeft(this._getAutoRotationAngle(t)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);
53
+ let s = this.minAzimuthAngle, o = this.maxAzimuthAngle;
54
+ isFinite(s) && isFinite(o) && (s < -Math.PI ? s += f : s > Math.PI && (s -= f), o < -Math.PI ? o += f : o > Math.PI && (o -= f), s <= o ? this._spherical.theta = Math.max(s, Math.min(o, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (s + o) / 2 ? Math.max(s, this._spherical.theta) : Math.min(o, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
55
+ let n = !1;
56
+ if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
57
+ this._spherical.radius = this._clampDistance(this._spherical.radius);
58
+ else {
59
+ const c = this._spherical.radius;
60
+ this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), n = c != this._spherical.radius;
61
+ }
62
+ if (d.setFromSpherical(this._spherical), d.applyQuaternion(this._quatInverse), e.copy(this.target).add(d), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) {
63
+ let c = null;
64
+ if (this.object.isPerspectiveCamera) {
65
+ const p = d.length();
66
+ c = this._clampDistance(p * this._scale);
67
+ const u = p - c;
68
+ this.object.position.addScaledVector(this._dollyDirection, u), this.object.updateMatrixWorld(), n = !!u;
69
+ } else if (this.object.isOrthographicCamera) {
70
+ const p = new E(this._mouse.x, this._mouse.y, 0);
71
+ p.unproject(this.object);
72
+ const u = this.object.zoom;
73
+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), n = u !== this.object.zoom;
74
+ const v = new E(this._mouse.x, this._mouse.y, 0);
75
+ v.unproject(this.object), this.object.position.sub(v).add(p), this.object.updateMatrixWorld(), c = d.length();
76
+ } else
77
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
78
+ c !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(c).add(this.object.position) : (z.origin.copy(this.object.position), z.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(z.direction)) < Tt ? this.object.lookAt(this.target) : (J.setFromNormalAndCoplanarPoint(this.object.up, this.target), z.intersectPlane(J, this.target))));
79
+ } else if (this.object.isOrthographicCamera) {
80
+ const c = this.object.zoom;
81
+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), c !== this.object.zoom && (this.object.updateProjectionMatrix(), n = !0);
82
+ }
83
+ return this._scale = 1, this._performCursorZoom = !1, n || this._lastPosition.distanceToSquared(this.object.position) > Y || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > Y || this._lastTargetPosition.distanceToSquared(this.target) > Y ? (this.dispatchEvent($), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
84
+ }
85
+ _getAutoRotationAngle(t) {
86
+ return t !== null ? f / 60 * this.autoRotateSpeed * t : f / 60 / 60 * this.autoRotateSpeed;
87
+ }
88
+ _getZoomScale(t) {
89
+ const e = Math.abs(t * 0.01);
90
+ return Math.pow(0.95, this.zoomSpeed * e);
91
+ }
92
+ _rotateLeft(t) {
93
+ this._sphericalDelta.theta -= t;
94
+ }
95
+ _rotateUp(t) {
96
+ this._sphericalDelta.phi -= t;
97
+ }
98
+ _panLeft(t, e) {
99
+ d.setFromMatrixColumn(e, 0), d.multiplyScalar(-t), this._panOffset.add(d);
100
+ }
101
+ _panUp(t, e) {
102
+ this.screenSpacePanning === !0 ? d.setFromMatrixColumn(e, 1) : (d.setFromMatrixColumn(e, 0), d.crossVectors(this.object.up, d)), d.multiplyScalar(t), this._panOffset.add(d);
103
+ }
104
+ // deltaX and deltaY are in pixels; right and down are positive
105
+ _pan(t, e) {
106
+ const s = this.domElement;
107
+ if (this.object.isPerspectiveCamera) {
108
+ const o = this.object.position;
109
+ d.copy(o).sub(this.target);
110
+ let n = d.length();
111
+ n *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * t * n / s.clientHeight, this.object.matrix), this._panUp(2 * e * n / s.clientHeight, this.object.matrix);
112
+ } else this.object.isOrthographicCamera ? (this._panLeft(t * (this.object.right - this.object.left) / this.object.zoom / s.clientWidth, this.object.matrix), this._panUp(e * (this.object.top - this.object.bottom) / this.object.zoom / s.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
113
+ }
114
+ _dollyOut(t) {
115
+ this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
116
+ }
117
+ _dollyIn(t) {
118
+ this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
119
+ }
120
+ _updateZoomParameters(t, e) {
121
+ if (!this.zoomToCursor)
122
+ return;
123
+ this._performCursorZoom = !0;
124
+ const s = this.domElement.getBoundingClientRect(), o = t - s.left, n = e - s.top, c = s.width, p = s.height;
125
+ this._mouse.x = o / c * 2 - 1, this._mouse.y = -(n / p) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
126
+ }
127
+ _clampDistance(t) {
128
+ return Math.max(this.minDistance, Math.min(this.maxDistance, t));
129
+ }
130
+ //
131
+ // event callbacks - update the object state
132
+ //
133
+ _handleMouseDownRotate(t) {
134
+ this._rotateStart.set(t.clientX, t.clientY);
135
+ }
136
+ _handleMouseDownDolly(t) {
137
+ this._updateZoomParameters(t.clientX, t.clientX), this._dollyStart.set(t.clientX, t.clientY);
138
+ }
139
+ _handleMouseDownPan(t) {
140
+ this._panStart.set(t.clientX, t.clientY);
141
+ }
142
+ _handleMouseMoveRotate(t) {
143
+ this._rotateEnd.set(t.clientX, t.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
144
+ const e = this.domElement;
145
+ this._rotateLeft(f * this._rotateDelta.x / e.clientHeight), this._rotateUp(f * this._rotateDelta.y / e.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
146
+ }
147
+ _handleMouseMoveDolly(t) {
148
+ this._dollyEnd.set(t.clientX, t.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.update();
149
+ }
150
+ _handleMouseMovePan(t) {
151
+ this._panEnd.set(t.clientX, t.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update();
152
+ }
153
+ _handleMouseWheel(t) {
154
+ this._updateZoomParameters(t.clientX, t.clientY), t.deltaY < 0 ? this._dollyIn(this._getZoomScale(t.deltaY)) : t.deltaY > 0 && this._dollyOut(this._getZoomScale(t.deltaY)), this.update();
155
+ }
156
+ _handleKeyDown(t) {
157
+ let e = !1;
158
+ switch (t.code) {
159
+ case this.keys.UP:
160
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(f * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), e = !0;
161
+ break;
162
+ case this.keys.BOTTOM:
163
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(-f * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), e = !0;
164
+ break;
165
+ case this.keys.LEFT:
166
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(f * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), e = !0;
167
+ break;
168
+ case this.keys.RIGHT:
169
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(-f * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), e = !0;
170
+ break;
171
+ }
172
+ e && (t.preventDefault(), this.update());
173
+ }
174
+ _handleTouchStartRotate(t) {
175
+ if (this._pointers.length === 1)
176
+ this._rotateStart.set(t.pageX, t.pageY);
177
+ else {
178
+ const e = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + e.x), o = 0.5 * (t.pageY + e.y);
179
+ this._rotateStart.set(s, o);
180
+ }
181
+ }
182
+ _handleTouchStartPan(t) {
183
+ if (this._pointers.length === 1)
184
+ this._panStart.set(t.pageX, t.pageY);
185
+ else {
186
+ const e = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + e.x), o = 0.5 * (t.pageY + e.y);
187
+ this._panStart.set(s, o);
188
+ }
189
+ }
190
+ _handleTouchStartDolly(t) {
191
+ const e = this._getSecondPointerPosition(t), s = t.pageX - e.x, o = t.pageY - e.y, n = Math.sqrt(s * s + o * o);
192
+ this._dollyStart.set(0, n);
193
+ }
194
+ _handleTouchStartDollyPan(t) {
195
+ this.enableZoom && this._handleTouchStartDolly(t), this.enablePan && this._handleTouchStartPan(t);
196
+ }
197
+ _handleTouchStartDollyRotate(t) {
198
+ this.enableZoom && this._handleTouchStartDolly(t), this.enableRotate && this._handleTouchStartRotate(t);
199
+ }
200
+ _handleTouchMoveRotate(t) {
201
+ if (this._pointers.length == 1)
202
+ this._rotateEnd.set(t.pageX, t.pageY);
203
+ else {
204
+ const s = this._getSecondPointerPosition(t), o = 0.5 * (t.pageX + s.x), n = 0.5 * (t.pageY + s.y);
205
+ this._rotateEnd.set(o, n);
206
+ }
207
+ this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
208
+ const e = this.domElement;
209
+ this._rotateLeft(f * this._rotateDelta.x / e.clientHeight), this._rotateUp(f * this._rotateDelta.y / e.clientHeight), this._rotateStart.copy(this._rotateEnd);
210
+ }
211
+ _handleTouchMovePan(t) {
212
+ if (this._pointers.length === 1)
213
+ this._panEnd.set(t.pageX, t.pageY);
214
+ else {
215
+ const e = this._getSecondPointerPosition(t), s = 0.5 * (t.pageX + e.x), o = 0.5 * (t.pageY + e.y);
216
+ this._panEnd.set(s, o);
217
+ }
218
+ this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
219
+ }
220
+ _handleTouchMoveDolly(t) {
221
+ const e = this._getSecondPointerPosition(t), s = t.pageX - e.x, o = t.pageY - e.y, n = Math.sqrt(s * s + o * o);
222
+ this._dollyEnd.set(0, n), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
223
+ const c = (t.pageX + e.x) * 0.5, p = (t.pageY + e.y) * 0.5;
224
+ this._updateZoomParameters(c, p);
225
+ }
226
+ _handleTouchMoveDollyPan(t) {
227
+ this.enableZoom && this._handleTouchMoveDolly(t), this.enablePan && this._handleTouchMovePan(t);
228
+ }
229
+ _handleTouchMoveDollyRotate(t) {
230
+ this.enableZoom && this._handleTouchMoveDolly(t), this.enableRotate && this._handleTouchMoveRotate(t);
231
+ }
232
+ // pointers
233
+ _addPointer(t) {
234
+ this._pointers.push(t.pointerId);
235
+ }
236
+ _removePointer(t) {
237
+ delete this._pointerPositions[t.pointerId];
238
+ for (let e = 0; e < this._pointers.length; e++)
239
+ if (this._pointers[e] == t.pointerId) {
240
+ this._pointers.splice(e, 1);
241
+ return;
242
+ }
243
+ }
244
+ _isTrackingPointer(t) {
245
+ for (let e = 0; e < this._pointers.length; e++)
246
+ if (this._pointers[e] == t.pointerId) return !0;
247
+ return !1;
248
+ }
249
+ _trackPointer(t) {
250
+ let e = this._pointerPositions[t.pointerId];
251
+ e === void 0 && (e = new P(), this._pointerPositions[t.pointerId] = e), e.set(t.pageX, t.pageY);
252
+ }
253
+ _getSecondPointerPosition(t) {
254
+ const e = t.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
255
+ return this._pointerPositions[e];
256
+ }
257
+ //
258
+ _customWheelEvent(t) {
259
+ const e = t.deltaMode, s = {
260
+ clientX: t.clientX,
261
+ clientY: t.clientY,
262
+ deltaY: t.deltaY
263
+ };
264
+ switch (e) {
265
+ case 1:
266
+ s.deltaY *= 16;
267
+ break;
268
+ case 2:
269
+ s.deltaY *= 100;
270
+ break;
271
+ }
272
+ return t.ctrlKey && !this._controlActive && (s.deltaY *= 10), s;
273
+ }
274
+ }
275
+ function Mt(i) {
276
+ this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(i.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(i) && (this._addPointer(i), i.pointerType === "touch" ? this._onTouchStart(i) : this._onMouseDown(i)));
277
+ }
278
+ function Rt(i) {
279
+ this.enabled !== !1 && (i.pointerType === "touch" ? this._onTouchMove(i) : this._onMouseMove(i));
280
+ }
281
+ function Ot(i) {
282
+ switch (this._removePointer(i), this._pointers.length) {
283
+ case 0:
284
+ this.domElement.releasePointerCapture(i.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(ot), this.state = l.NONE;
285
+ break;
286
+ case 1:
287
+ const t = this._pointers[0], e = this._pointerPositions[t];
288
+ this._onTouchStart({ pointerId: t, pageX: e.x, pageY: e.y });
289
+ break;
290
+ }
291
+ }
292
+ function xt(i) {
293
+ let t;
294
+ switch (i.button) {
295
+ case 0:
296
+ t = this.mouseButtons.LEFT;
297
+ break;
298
+ case 1:
299
+ t = this.mouseButtons.MIDDLE;
300
+ break;
301
+ case 2:
302
+ t = this.mouseButtons.RIGHT;
303
+ break;
304
+ default:
305
+ t = -1;
306
+ }
307
+ switch (t) {
308
+ case C.DOLLY:
309
+ if (this.enableZoom === !1) return;
310
+ this._handleMouseDownDolly(i), this.state = l.DOLLY;
311
+ break;
312
+ case C.ROTATE:
313
+ if (i.ctrlKey || i.metaKey || i.shiftKey) {
314
+ if (this.enablePan === !1) return;
315
+ this._handleMouseDownPan(i), this.state = l.PAN;
316
+ } else {
317
+ if (this.enableRotate === !1) return;
318
+ this._handleMouseDownRotate(i), this.state = l.ROTATE;
319
+ }
320
+ break;
321
+ case C.PAN:
322
+ if (i.ctrlKey || i.metaKey || i.shiftKey) {
323
+ if (this.enableRotate === !1) return;
324
+ this._handleMouseDownRotate(i), this.state = l.ROTATE;
325
+ } else {
326
+ if (this.enablePan === !1) return;
327
+ this._handleMouseDownPan(i), this.state = l.PAN;
328
+ }
329
+ break;
330
+ default:
331
+ this.state = l.NONE;
332
+ }
333
+ this.state !== l.NONE && this.dispatchEvent(F);
334
+ }
335
+ function Ct(i) {
336
+ switch (this.state) {
337
+ case l.ROTATE:
338
+ if (this.enableRotate === !1) return;
339
+ this._handleMouseMoveRotate(i);
340
+ break;
341
+ case l.DOLLY:
342
+ if (this.enableZoom === !1) return;
343
+ this._handleMouseMoveDolly(i);
344
+ break;
345
+ case l.PAN:
346
+ if (this.enablePan === !1) return;
347
+ this._handleMouseMovePan(i);
348
+ break;
349
+ }
350
+ }
351
+ function Lt(i) {
352
+ this.enabled === !1 || this.enableZoom === !1 || this.state !== l.NONE || (i.preventDefault(), this.dispatchEvent(F), this._handleMouseWheel(this._customWheelEvent(i)), this.dispatchEvent(ot));
353
+ }
354
+ function At(i) {
355
+ this.enabled !== !1 && this._handleKeyDown(i);
356
+ }
357
+ function kt(i) {
358
+ switch (this._trackPointer(i), this._pointers.length) {
359
+ case 1:
360
+ switch (this.touches.ONE) {
361
+ case x.ROTATE:
362
+ if (this.enableRotate === !1) return;
363
+ this._handleTouchStartRotate(i), this.state = l.TOUCH_ROTATE;
364
+ break;
365
+ case x.PAN:
366
+ if (this.enablePan === !1) return;
367
+ this._handleTouchStartPan(i), this.state = l.TOUCH_PAN;
368
+ break;
369
+ default:
370
+ this.state = l.NONE;
371
+ }
372
+ break;
373
+ case 2:
374
+ switch (this.touches.TWO) {
375
+ case x.DOLLY_PAN:
376
+ if (this.enableZoom === !1 && this.enablePan === !1) return;
377
+ this._handleTouchStartDollyPan(i), this.state = l.TOUCH_DOLLY_PAN;
378
+ break;
379
+ case x.DOLLY_ROTATE:
380
+ if (this.enableZoom === !1 && this.enableRotate === !1) return;
381
+ this._handleTouchStartDollyRotate(i), this.state = l.TOUCH_DOLLY_ROTATE;
382
+ break;
383
+ default:
384
+ this.state = l.NONE;
385
+ }
386
+ break;
387
+ default:
388
+ this.state = l.NONE;
389
+ }
390
+ this.state !== l.NONE && this.dispatchEvent(F);
391
+ }
392
+ function jt(i) {
393
+ switch (this._trackPointer(i), this.state) {
394
+ case l.TOUCH_ROTATE:
395
+ if (this.enableRotate === !1) return;
396
+ this._handleTouchMoveRotate(i), this.update();
397
+ break;
398
+ case l.TOUCH_PAN:
399
+ if (this.enablePan === !1) return;
400
+ this._handleTouchMovePan(i), this.update();
401
+ break;
402
+ case l.TOUCH_DOLLY_PAN:
403
+ if (this.enableZoom === !1 && this.enablePan === !1) return;
404
+ this._handleTouchMoveDollyPan(i), this.update();
405
+ break;
406
+ case l.TOUCH_DOLLY_ROTATE:
407
+ if (this.enableZoom === !1 && this.enableRotate === !1) return;
408
+ this._handleTouchMoveDollyRotate(i), this.update();
409
+ break;
410
+ default:
411
+ this.state = l.NONE;
412
+ }
413
+ }
414
+ function zt(i) {
415
+ this.enabled !== !1 && i.preventDefault();
416
+ }
417
+ function Nt(i) {
418
+ i.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
419
+ }
420
+ function It(i) {
421
+ i.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
422
+ }
423
+ const Ut = { class: "present3d-container" }, Yt = { class: "header" }, Zt = { class: "controls" }, Kt = { class: "material-icons" }, Ht = { class: "material-icons" }, Ft = {
424
+ key: 0,
425
+ class: "error"
426
+ }, Wt = { class: "script-source" }, Vt = ["disabled"], Xt = /* @__PURE__ */ tt({
427
+ __name: "View",
428
+ props: {
429
+ selectedResult: {}
430
+ },
431
+ emits: ["updateResult"],
432
+ setup(i, { emit: t }) {
433
+ var G;
434
+ const e = i, s = t, o = R(((G = e.selectedResult.data) == null ? void 0 : G.script) ?? ""), n = R(null), c = R(null), p = R(!1), u = R(!0), v = et(() => {
435
+ var a;
436
+ return o.value !== ((a = e.selectedResult.data) == null ? void 0 : a.script);
437
+ });
438
+ let y, m, w, r, b, S, L = [], D = null, M = null;
439
+ it(() => {
440
+ nt(), U(), W(), q(() => {
441
+ V();
442
+ });
443
+ }), st(() => {
444
+ dt();
445
+ }), O(
446
+ () => {
447
+ var a;
448
+ return (a = e.selectedResult.data) == null ? void 0 : a.script;
449
+ },
450
+ () => {
451
+ U();
452
+ }
453
+ ), O(p, () => {
454
+ U();
455
+ }), O(u, (a) => {
456
+ S && (S.visible = a);
457
+ });
458
+ function nt() {
459
+ if (!n.value) return;
460
+ y = new g.Scene(), y.background = new g.Color(1710618);
461
+ const a = n.value.clientWidth, h = n.value.clientHeight;
462
+ m = new g.PerspectiveCamera(50, a / h, 0.1, 1e3), m.position.set(5, 5, 10), m.lookAt(0, 0, 0), w = new g.WebGLRenderer({ antialias: !0 }), w.setSize(a, h), w.setPixelRatio(window.devicePixelRatio), n.value.appendChild(w.domElement), r = new vt(m, w.domElement), r.enableDamping = !0, r.dampingFactor = 0.05, r.addEventListener("change", X);
463
+ const T = new g.AmbientLight(16777215, 0.6);
464
+ y.add(T);
465
+ const A = new g.DirectionalLight(16777215, 0.8);
466
+ A.position.set(10, 10, 10), y.add(A), S = new g.GridHelper(20, 20, 4473924, 2236962), S.visible = u.value, y.add(S), window.addEventListener("resize", I), M = new ResizeObserver(() => {
467
+ I();
468
+ }), M.observe(n.value);
469
+ }
470
+ function I() {
471
+ if (!n.value) return;
472
+ const a = n.value.clientWidth, h = n.value.clientHeight;
473
+ m.aspect = a / h, m.updateProjectionMatrix(), w.setSize(a, h);
474
+ }
475
+ function U() {
476
+ var a;
477
+ try {
478
+ L.forEach((_t) => y.remove(_t)), L = [];
479
+ const h = (a = e.selectedResult.data) == null ? void 0 : a.script;
480
+ if (!h) return;
481
+ const T = N(h), A = Z(T, { wireframe: p.value });
482
+ y.add(A), L.push(A), c.value = null;
483
+ } catch (h) {
484
+ c.value = h instanceof Error ? h.message : "Unknown error", console.error("ShapeScript parse error:", h);
485
+ }
486
+ }
487
+ function W() {
488
+ b = requestAnimationFrame(W), r.update(), w.render(y, m);
489
+ }
490
+ function rt() {
491
+ m.position.set(5, 5, 10), m.lookAt(0, 0, 0), r.reset();
492
+ }
493
+ function V() {
494
+ var h, T;
495
+ if (!m || !r || !((T = (h = e.selectedResult) == null ? void 0 : h.viewState) != null && T.cameraState))
496
+ return;
497
+ const a = e.selectedResult.viewState.cameraState;
498
+ a.position && m.position.set(a.position.x, a.position.y, a.position.z), a.target && r.target.set(a.target.x, a.target.y, a.target.z), m.updateProjectionMatrix(), r.update();
499
+ }
500
+ function ht() {
501
+ return {
502
+ position: {
503
+ x: m.position.x,
504
+ y: m.position.y,
505
+ z: m.position.z
506
+ },
507
+ target: {
508
+ x: r.target.x,
509
+ y: r.target.y,
510
+ z: r.target.z
511
+ }
512
+ };
513
+ }
514
+ function X() {
515
+ D !== null && clearTimeout(D), D = window.setTimeout(() => {
516
+ lt();
517
+ }, 500);
518
+ }
519
+ function lt() {
520
+ const a = {
521
+ ...e.selectedResult,
522
+ viewState: {
523
+ cameraState: ht()
524
+ }
525
+ };
526
+ s("updateResult", a);
527
+ }
528
+ function ct() {
529
+ p.value = !p.value;
530
+ }
531
+ function pt() {
532
+ u.value = !u.value;
533
+ }
534
+ function dt() {
535
+ D !== null && clearTimeout(D), b && cancelAnimationFrame(b), w && w.dispose(), r && (r.removeEventListener("change", X), r.dispose()), M && M.disconnect(), window.removeEventListener("resize", I);
536
+ }
537
+ function ut() {
538
+ }
539
+ function mt() {
540
+ try {
541
+ N(o.value);
542
+ const a = {
543
+ ...e.selectedResult,
544
+ data: {
545
+ script: o.value
546
+ }
547
+ };
548
+ s("updateResult", a);
549
+ } catch (a) {
550
+ c.value = a instanceof Error ? a.message : "Invalid ShapeScript", console.error("Script validation failed:", a);
551
+ }
552
+ }
553
+ return O(
554
+ () => {
555
+ var a;
556
+ return (a = e.selectedResult.data) == null ? void 0 : a.script;
557
+ },
558
+ (a) => {
559
+ a && (o.value = a);
560
+ }
561
+ ), O(
562
+ () => e.selectedResult,
563
+ () => {
564
+ q(() => {
565
+ V();
566
+ });
567
+ }
568
+ ), (a, h) => (H(), K("div", Ut, [
569
+ _("div", Yt, [
570
+ _("h1", null, k(i.selectedResult.title || "3D Visualization"), 1),
571
+ _("div", Zt, [
572
+ _("button", {
573
+ onClick: rt,
574
+ class: "control-btn"
575
+ }, [...h[1] || (h[1] = [
576
+ _("span", { class: "material-icons" }, "refresh", -1),
577
+ j(" Reset Camera ", -1)
578
+ ])]),
579
+ _("button", {
580
+ onClick: ct,
581
+ class: "control-btn"
582
+ }, [
583
+ _("span", Kt, k(p.value ? "grid_off" : "grid_on"), 1),
584
+ h[2] || (h[2] = j(" Wireframe ", -1))
585
+ ]),
586
+ _("button", {
587
+ onClick: pt,
588
+ class: "control-btn"
589
+ }, [
590
+ _("span", Ht, k(u.value ? "visibility_off" : "visibility"), 1),
591
+ h[3] || (h[3] = j(" Grid ", -1))
592
+ ])
593
+ ])
594
+ ]),
595
+ c.value ? (H(), K("div", Ft, [
596
+ h[4] || (h[4] = _("strong", null, "Parse Error:", -1)),
597
+ j(" " + k(c.value), 1)
598
+ ])) : gt("", !0),
599
+ _("div", {
600
+ class: "viewport",
601
+ ref_key: "viewport",
602
+ ref: n
603
+ }, null, 512),
604
+ _("details", Wt, [
605
+ h[5] || (h[5] = _("summary", null, "Edit ShapeScript Source", -1)),
606
+ yt(_("textarea", {
607
+ "onUpdate:modelValue": h[0] || (h[0] = (T) => o.value = T),
608
+ onInput: ut,
609
+ class: "script-editor",
610
+ spellcheck: "false"
611
+ }, null, 544), [
612
+ [wt, o.value]
613
+ ]),
614
+ _("button", {
615
+ onClick: mt,
616
+ class: "apply-btn",
617
+ disabled: !v.value
618
+ }, " Apply Changes ", 8, Vt)
619
+ ])
620
+ ]));
621
+ }
622
+ }), at = (i, t) => {
623
+ const e = i.__vccOpts || i;
624
+ for (const [s, o] of t)
625
+ e[s] = o;
626
+ return e;
627
+ }, Gt = /* @__PURE__ */ at(Xt, [["__scopeId", "data-v-daa337a0"]]), qt = { class: "preview-container" }, Bt = { class: "preview-title" }, Qt = /* @__PURE__ */ tt({
628
+ __name: "Preview",
629
+ props: {
630
+ result: {}
631
+ },
632
+ setup(i) {
633
+ const t = i, e = et(() => t.result.title || "3D Visualization"), s = R(null);
634
+ let o, n, c, p, u = null;
635
+ it(() => {
636
+ v();
637
+ }), st(() => {
638
+ w();
639
+ }), O(
640
+ () => {
641
+ var r;
642
+ return (r = t.result.data) == null ? void 0 : r.script;
643
+ },
644
+ () => {
645
+ m();
646
+ }
647
+ );
648
+ function v() {
649
+ var r;
650
+ if (s.value)
651
+ try {
652
+ o = new g.Scene(), o.background = new g.Color(2763322);
653
+ const b = s.value.clientWidth || 200, S = s.value.clientHeight || 150;
654
+ n = new g.PerspectiveCamera(50, b / S, 0.1, 1e3), n.position.set(4, 4, 8), n.lookAt(0, 0, 0), c = new g.WebGLRenderer({ antialias: !0, alpha: !1 }), c.setSize(b, S), c.setPixelRatio(Math.min(window.devicePixelRatio, 2)), s.value.appendChild(c.domElement);
655
+ const L = new g.AmbientLight(16777215, 0.6);
656
+ o.add(L);
657
+ const D = new g.DirectionalLight(16777215, 0.8);
658
+ if (D.position.set(5, 5, 5), o.add(D), !((r = t.result.data) != null && r.script)) return;
659
+ const M = N(t.result.data.script);
660
+ u = Z(M, { wireframe: !1 }), o.add(u), y();
661
+ } catch (b) {
662
+ console.error("Preview render error:", b);
663
+ }
664
+ }
665
+ function y() {
666
+ p = requestAnimationFrame(y);
667
+ const r = Date.now() * 5e-4;
668
+ n.position.x = Math.cos(r) * 8, n.position.z = Math.sin(r) * 8, n.lookAt(0, 0, 0), c.render(o, n);
669
+ }
670
+ function m() {
671
+ var r;
672
+ if (!(!o || !((r = t.result.data) != null && r.script)))
673
+ try {
674
+ u && o.remove(u);
675
+ const b = N(t.result.data.script);
676
+ u = Z(b, { wireframe: !1 }), o.add(u);
677
+ } catch (b) {
678
+ console.error("Preview reload error:", b);
679
+ }
680
+ }
681
+ function w() {
682
+ p && cancelAnimationFrame(p), c && c.dispose();
683
+ }
684
+ return (r, b) => (H(), K("div", qt, [
685
+ _("div", {
686
+ ref_key: "previewViewport",
687
+ ref: s,
688
+ class: "preview-viewport"
689
+ }, null, 512),
690
+ _("div", Bt, k(e.value), 1)
691
+ ]));
692
+ }
693
+ }), $t = /* @__PURE__ */ at(Qt, [["__scopeId", "data-v-75941188"]]), Jt = "present3D", te = `Use the ${Jt} tool to create interactive 3D visualizations when the user requests:
694
+ - 3D models or shapes
695
+ - Mathematical visualizations (surfaces, functions, geometric patterns)
696
+ - Molecular or atomic structures
697
+ - Data visualization in 3D (scatter plots, surface plots)
698
+ - Architectural layouts
699
+ - Game boards or 3D game states
700
+ - Any spatial or geometric concepts
701
+
702
+ ## ShapeScript Language Features (FULL SUPPORT):
703
+
704
+ ### Variables & Expressions:
705
+ - Define variables: define radius 2, define spacing 1.5
706
+ - Use expressions: position (i * 2) 0 0, size (radius * 1.5)
707
+ - Math operators: +, -, *, /, % with proper precedence
708
+ - Parentheses for grouping: (2 + 3) * 4
709
+
710
+ ### Control Flow:
711
+
712
+ For loops with variables (use loop variable in calculations):
713
+ for i in 1 to 5 {
714
+ cube { position (i * 2 - 6) 0 0 size 1 }
715
+ }
716
+
717
+ For loops with step:
718
+ for i in 0 to 10 step 2 {
719
+ sphere { position 0 i 0 }
720
+ }
721
+
722
+ If/else conditionals:
723
+ if x > 0 {
724
+ sphere
725
+ } else {
726
+ cube
727
+ }
728
+
729
+ Switch statements for multiple cases
730
+
731
+ ### Built-in Functions:
732
+ - Math: round, floor, ceil, abs, sign, sqrt, pow, min, max
733
+ - Trig: sin, cos, tan, asin, acos, atan, atan2 (radians!)
734
+ - Vector: dot, cross, length, normalize, sum
735
+
736
+ CRITICAL: Function calls require NO space between name and (
737
+ - sin(x) ✓ correct
738
+ - sin (x) ✗ wrong - this is NOT a function call!
739
+
740
+ ### Best Practices:
741
+ 1. Use variables for repeated values
742
+ 2. Use loop variables (i) for positioning and calculations
743
+ 3. Use trig functions for circular/spiral patterns
744
+ 4. Use conditionals for parametric designs
745
+ 5. Keep code readable with meaningful variable names
746
+
747
+ ### Common Patterns:
748
+
749
+ Linear arrangement:
750
+ for i in 1 to 5 {
751
+ cube { position (i * 2) 0 0 }
752
+ }
753
+
754
+ Circular pattern:
755
+ define count 12
756
+ for i in 1 to count {
757
+ define angle ((i / count) * 6.283)
758
+ cube { position (cos(angle) * 3) 0 (sin(angle) * 3) }
759
+ }
760
+
761
+ Parametric surface:
762
+ for x in -5 to 5 {
763
+ for z in -5 to 5 {
764
+ define y (sin(x * 0.5) * cos(z * 0.5))
765
+ cube { position (x * 0.3) y (z * 0.3) size 0.2 }
766
+ }
767
+ }
768
+
769
+ ### Primitives & CSG:
770
+ Shapes: cube, sphere, cylinder, cone, torus
771
+ CSG: union, difference, intersection, xor, stencil
772
+ Properties: position, rotation, size, color, opacity
773
+
774
+ Keep visualizations clear, well-organized, and leverage the full power of expressions and control flow.`, ee = {
775
+ ...bt,
776
+ viewComponent: Gt,
777
+ previewComponent: $t,
778
+ samples: ft,
779
+ systemPrompt: te
780
+ }, ae = { plugin: ee };
781
+ export {
782
+ $t as Preview,
783
+ te as SYSTEM_PROMPT,
784
+ he as TOOL_DEFINITION,
785
+ Jt as TOOL_NAME,
786
+ Gt as View,
787
+ Z as astToThreeJS,
788
+ ae as default,
789
+ le as executePresent3D,
790
+ N as parseShapeScript,
791
+ ee as plugin,
792
+ bt as pluginCore,
793
+ ft as samples
794
+ };