@xiping/react-components 1.0.20 → 1.0.22
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/cjs/components/confetti-button/index.d.ts +24 -0
- package/dist/cjs/components/confetti-button/index.js +1 -0
- package/dist/cjs/components/txt-editor/TxtEditor.js +1 -1
- package/dist/cjs/hooks/useStayTimeReport.d.ts +6 -0
- package/dist/cjs/hooks/useStayTimeReport.js +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/node_modules/.pnpm/3d-force-graph@1.78.2/node_modules/3d-force-graph/dist/3d-force-graph.js +28 -0
- package/dist/cjs/node_modules/.pnpm/@tweenjs_tween.js@25.0.0/node_modules/@tweenjs/tween.js/dist/tween.esm.js +1 -0
- package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/bowser.js +6 -0
- package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/constants.js +1 -0
- package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-browsers.js +1 -0
- package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-engines.js +1 -0
- package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-os.js +1 -0
- package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-platforms.js +1 -0
- package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser.js +1 -0
- package/dist/cjs/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/utils.js +1 -0
- package/dist/cjs/node_modules/.pnpm/canvas-confetti@1.9.3/node_modules/canvas-confetti/dist/confetti.module.js +2 -0
- package/dist/cjs/node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/max.js +1 -0
- package/dist/cjs/node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/min.js +1 -0
- package/dist/cjs/node_modules/.pnpm/react-force-graph-3d@1.28.0_react@19.1.0/node_modules/react-force-graph-3d/dist/react-force-graph-3d.js +1 -0
- package/dist/cjs/node_modules/.pnpm/three-forcegraph@1.43.0_three@0.178.0/node_modules/three-forcegraph/dist/three-forcegraph.js +3 -0
- package/dist/cjs/node_modules/.pnpm/three-render-objects@1.40.4_three@0.178.0/node_modules/three-render-objects/dist/three-render-objects.js +18 -0
- package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.core.js +44 -0
- package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.module.js +3784 -0
- package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.webgpu.js +392 -0
- package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/DragControls.js +1 -0
- package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/FlyControls.js +1 -0
- package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -0
- package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/controls/TrackballControls.js +1 -0
- package/dist/cjs/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/ShaderPass.js +1 -0
- package/dist/cjs/react-components.css +1 -1
- package/dist/es/components/confetti-button/index.d.ts +24 -0
- package/dist/es/components/confetti-button/index.js +77 -0
- package/dist/es/components/txt-editor/TxtEditor.js +1 -1
- package/dist/es/hooks/useStayTimeReport.d.ts +6 -0
- package/dist/es/hooks/useStayTimeReport.js +31 -0
- package/dist/es/index.d.ts +2 -0
- package/dist/es/index.js +31 -26
- package/dist/es/node_modules/.pnpm/{3d-force-graph@1.77.0 → 3d-force-graph@1.78.2}/node_modules/3d-force-graph/dist/3d-force-graph.js +10 -10
- package/dist/es/node_modules/.pnpm/@tweenjs_tween.js@25.0.0/node_modules/@tweenjs/tween.js/dist/tween.esm.js +396 -0
- package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/bowser.js +55 -0
- package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/constants.js +113 -0
- package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-browsers.js +404 -0
- package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-engines.js +78 -0
- package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-os.js +159 -0
- package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser-platforms.js +238 -0
- package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/parser.js +303 -0
- package/dist/es/node_modules/.pnpm/bowser@2.11.0/node_modules/bowser/src/utils.js +280 -0
- package/dist/es/node_modules/.pnpm/canvas-confetti@1.9.3/node_modules/canvas-confetti/dist/confetti.module.js +409 -0
- package/dist/es/node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/max.js +15 -0
- package/dist/es/node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/min.js +15 -0
- package/dist/es/node_modules/.pnpm/{react-force-graph-3d@1.27.0_react@18.3.1 → react-force-graph-3d@1.28.0_react@19.1.0}/node_modules/react-force-graph-3d/dist/react-force-graph-3d.js +5 -2
- package/dist/es/node_modules/.pnpm/three-forcegraph@1.43.0_three@0.178.0/node_modules/three-forcegraph/dist/three-forcegraph.js +1037 -0
- package/dist/es/node_modules/.pnpm/{three-render-objects@1.40.2_three@0.171.0 → three-render-objects@1.40.4_three@0.178.0}/node_modules/three-render-objects/dist/three-render-objects.js +30 -30
- package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.core.js +13236 -0
- package/dist/es/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/build/three.module.js +3379 -3325
- package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/build/three.webgpu.js +24475 -0
- package/dist/es/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/controls/DragControls.js +15 -8
- package/dist/es/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/controls/FlyControls.js +26 -20
- package/dist/es/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/controls/OrbitControls.js +47 -10
- package/dist/es/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/controls/TrackballControls.js +16 -4
- package/dist/es/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/postprocessing/EffectComposer.js +62 -0
- package/dist/es/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/postprocessing/MaskPass.js +31 -0
- package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/Pass.js +89 -0
- package/dist/es/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/postprocessing/RenderPass.js +21 -0
- package/dist/es/node_modules/.pnpm/three@0.178.0/node_modules/three/examples/jsm/postprocessing/ShaderPass.js +46 -0
- package/dist/es/react-components.css +1 -1
- package/package.json +32 -30
- package/dist/cjs/node_modules/.pnpm/3d-force-graph@1.77.0/node_modules/3d-force-graph/dist/3d-force-graph.js +0 -28
- package/dist/cjs/node_modules/.pnpm/@tweenjs_tween.js@23.1.3/node_modules/@tweenjs/tween.js/dist/tween.esm.js +0 -1
- package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/ascending.js +0 -1
- package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/bisect.js +0 -1
- package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/bisector.js +0 -1
- package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/max.js +0 -1
- package/dist/cjs/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/min.js +0 -1
- package/dist/cjs/node_modules/.pnpm/react-force-graph-3d@1.27.0_react@18.3.1/node_modules/react-force-graph-3d/dist/react-force-graph-3d.js +0 -1
- package/dist/cjs/node_modules/.pnpm/three-forcegraph@1.42.13_three@0.171.0/node_modules/three-forcegraph/dist/three-forcegraph.js +0 -3
- package/dist/cjs/node_modules/.pnpm/three-render-objects@1.40.2_three@0.171.0/node_modules/three-render-objects/dist/three-render-objects.js +0 -18
- package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.core.js +0 -44
- package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.module.js +0 -3789
- package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.webgpu.js +0 -373
- package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/DragControls.js +0 -1
- package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/FlyControls.js +0 -1
- package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/OrbitControls.js +0 -1
- package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/controls/TrackballControls.js +0 -1
- package/dist/cjs/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/ShaderPass.js +0 -1
- package/dist/es/node_modules/.pnpm/@tweenjs_tween.js@23.1.3/node_modules/@tweenjs/tween.js/dist/tween.esm.js +0 -379
- package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/ascending.js +0 -6
- package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/bisect.js +0 -3
- package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/bisector.js +0 -27
- package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/max.js +0 -17
- package/dist/es/node_modules/.pnpm/d3-array@1.2.4/node_modules/d3-array/src/min.js +0 -17
- package/dist/es/node_modules/.pnpm/three-forcegraph@1.42.13_three@0.171.0/node_modules/three-forcegraph/dist/three-forcegraph.js +0 -1020
- package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.core.js +0 -6662
- package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/build/three.webgpu.js +0 -13421
- package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/Pass.js +0 -42
- package/dist/es/node_modules/.pnpm/three@0.171.0/node_modules/three/examples/jsm/postprocessing/ShaderPass.js +0 -23
- /package/dist/cjs/node_modules/.pnpm/{@monaco-editor_react@4.7.0_monaco-editor@0.52.2_react-dom@18.3.1_react@18.3.1__react@18.3.1 → @monaco-editor_react@4.7.0_monaco-editor@0.52.2_react-dom@19.1.0_react@19.1.0__react@19.1.0}/node_modules/@monaco-editor/react/dist/index.js +0 -0
- /package/dist/cjs/node_modules/.pnpm/{react-kapsule@2.5.7_react@18.3.1 → react-kapsule@2.5.7_react@19.1.0}/node_modules/react-kapsule/dist/react-kapsule.js +0 -0
- /package/dist/cjs/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/postprocessing/EffectComposer.js +0 -0
- /package/dist/cjs/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/postprocessing/MaskPass.js +0 -0
- /package/dist/cjs/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/postprocessing/Pass.js +0 -0
- /package/dist/cjs/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/postprocessing/RenderPass.js +0 -0
- /package/dist/cjs/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/shaders/CopyShader.js +0 -0
- /package/dist/es/node_modules/.pnpm/{@monaco-editor_react@4.7.0_monaco-editor@0.52.2_react-dom@18.3.1_react@18.3.1__react@18.3.1 → @monaco-editor_react@4.7.0_monaco-editor@0.52.2_react-dom@19.1.0_react@19.1.0__react@19.1.0}/node_modules/@monaco-editor/react/dist/index.js +0 -0
- /package/dist/es/node_modules/.pnpm/{react-kapsule@2.5.7_react@18.3.1 → react-kapsule@2.5.7_react@19.1.0}/node_modules/react-kapsule/dist/react-kapsule.js +0 -0
- /package/dist/es/node_modules/.pnpm/{three@0.171.0 → three@0.178.0}/node_modules/three/examples/jsm/shaders/CopyShader.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../../build/three.module.js";
|
|
2
|
-
import { Controls as C, Raycaster as g, MOUSE as d, TOUCH as E, Vector2 as v, Plane as A, Vector3 as
|
|
3
|
-
const l = new A(), r = new v(), y = new
|
|
2
|
+
import { Controls as C, Raycaster as g, MOUSE as d, TOUCH as E, Vector2 as v, Plane as A, Vector3 as u, Matrix4 as j } from "../../../build/three.core.js";
|
|
3
|
+
const l = new A(), r = new v(), y = new u(), f = new v(), m = new v(), p = new u(), b = new u(), P = new j(), T = new u(), _ = new u();
|
|
4
4
|
let o = null, i = null;
|
|
5
5
|
const a = [], c = {
|
|
6
6
|
NONE: -1,
|
|
@@ -8,11 +8,18 @@ const a = [], c = {
|
|
|
8
8
|
ROTATE: 1
|
|
9
9
|
};
|
|
10
10
|
class L extends C {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a new controls instance.
|
|
13
|
+
*
|
|
14
|
+
* @param {Array<Object3D>} objects - An array of draggable 3D objects.
|
|
15
|
+
* @param {Camera} camera - The camera of the rendered scene.
|
|
16
|
+
* @param {?HTMLDOMElement} [domElement=null] - The HTML DOM element used for event listeners.
|
|
17
|
+
*/
|
|
11
18
|
constructor(t, e, s = null) {
|
|
12
|
-
super(e, s), this.objects = t, this.recursive = !0, this.transformGroup = !1, this.rotateSpeed = 1, this.raycaster = new g(), this.mouseButtons = { LEFT: d.PAN, MIDDLE: d.PAN, RIGHT: d.ROTATE }, this.touches = { ONE: E.PAN }, this._onPointerMove = x.bind(this), this._onPointerDown = O.bind(this), this._onPointerCancel = D.bind(this), this._onContextMenu = R.bind(this), s !== null && this.connect();
|
|
19
|
+
super(e, s), this.objects = t, this.recursive = !0, this.transformGroup = !1, this.rotateSpeed = 1, this.raycaster = new g(), this.mouseButtons = { LEFT: d.PAN, MIDDLE: d.PAN, RIGHT: d.ROTATE }, this.touches = { ONE: E.PAN }, this._onPointerMove = x.bind(this), this._onPointerDown = O.bind(this), this._onPointerCancel = D.bind(this), this._onContextMenu = R.bind(this), s !== null && this.connect(s);
|
|
13
20
|
}
|
|
14
|
-
connect() {
|
|
15
|
-
this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointerup", this._onPointerCancel), this.domElement.addEventListener("pointerleave", this._onPointerCancel), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "none";
|
|
21
|
+
connect(t) {
|
|
22
|
+
super.connect(t), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointerup", this._onPointerCancel), this.domElement.addEventListener("pointerleave", this._onPointerCancel), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "none";
|
|
16
23
|
}
|
|
17
24
|
disconnect() {
|
|
18
25
|
this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointerup", this._onPointerCancel), this.domElement.removeEventListener("pointerleave", this._onPointerCancel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "auto", this.domElement.style.cursor = "";
|
|
@@ -81,19 +88,19 @@ function x(n) {
|
|
|
81
88
|
const t = this.object, e = this.domElement, s = this.raycaster;
|
|
82
89
|
if (this.enabled !== !1) {
|
|
83
90
|
if (this._updatePointer(n), s.setFromCamera(r, t), o)
|
|
84
|
-
this.state === c.PAN ? s.ray.intersectPlane(l, p) && o.position.copy(p.sub(y).applyMatrix4(P)) : this.state === c.ROTATE && (f.subVectors(r,
|
|
91
|
+
this.state === c.PAN ? s.ray.intersectPlane(l, p) && o.position.copy(p.sub(y).applyMatrix4(P)) : this.state === c.ROTATE && (f.subVectors(r, m).multiplyScalar(this.rotateSpeed), o.rotateOnWorldAxis(T, f.x), o.rotateOnWorldAxis(_.normalize(), -f.y)), this.dispatchEvent({ type: "drag", object: o }), m.copy(r);
|
|
85
92
|
else if (n.pointerType === "mouse" || n.pointerType === "pen")
|
|
86
93
|
if (a.length = 0, s.setFromCamera(r, t), s.intersectObjects(this.objects, this.recursive, a), a.length > 0) {
|
|
87
94
|
const h = a[0].object;
|
|
88
95
|
l.setFromNormalAndCoplanarPoint(t.getWorldDirection(l.normal), b.setFromMatrixPosition(h.matrixWorld)), i !== h && i !== null && (this.dispatchEvent({ type: "hoveroff", object: i }), e.style.cursor = "auto", i = null), i !== h && (this.dispatchEvent({ type: "hoveron", object: h }), e.style.cursor = "pointer", i = h);
|
|
89
96
|
} else
|
|
90
97
|
i !== null && (this.dispatchEvent({ type: "hoveroff", object: i }), e.style.cursor = "auto", i = null);
|
|
91
|
-
|
|
98
|
+
m.copy(r);
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
function O(n) {
|
|
95
102
|
const t = this.object, e = this.domElement, s = this.raycaster;
|
|
96
|
-
this.enabled !== !1 && (this._updatePointer(n), this._updateState(n), a.length = 0, s.setFromCamera(r, t), s.intersectObjects(this.objects, this.recursive, a), a.length > 0 && (this.transformGroup === !0 ? o = w(a[0].object) : o = a[0].object, l.setFromNormalAndCoplanarPoint(t.getWorldDirection(l.normal), b.setFromMatrixPosition(o.matrixWorld)), s.ray.intersectPlane(l, p) && (this.state === c.PAN ? (P.copy(o.parent.matrixWorld).invert(), y.copy(p).sub(b.setFromMatrixPosition(o.matrixWorld))) : this.state === c.ROTATE && (T.set(0, 1, 0).applyQuaternion(t.quaternion).normalize(), _.set(1, 0, 0).applyQuaternion(t.quaternion).normalize())), e.style.cursor = "move", this.dispatchEvent({ type: "dragstart", object: o })),
|
|
103
|
+
this.enabled !== !1 && (this._updatePointer(n), this._updateState(n), a.length = 0, s.setFromCamera(r, t), s.intersectObjects(this.objects, this.recursive, a), a.length > 0 && (this.transformGroup === !0 ? o = w(a[0].object) : o = a[0].object, l.setFromNormalAndCoplanarPoint(t.getWorldDirection(l.normal), b.setFromMatrixPosition(o.matrixWorld)), s.ray.intersectPlane(l, p) && (this.state === c.PAN ? (P.copy(o.parent.matrixWorld).invert(), y.copy(p).sub(b.setFromMatrixPosition(o.matrixWorld))) : this.state === c.ROTATE && (T.set(0, 1, 0).applyQuaternion(t.quaternion).normalize(), _.set(1, 0, 0).applyQuaternion(t.quaternion).normalize())), e.style.cursor = "move", this.dispatchEvent({ type: "dragstart", object: o })), m.copy(r));
|
|
97
104
|
}
|
|
98
105
|
function D() {
|
|
99
106
|
this.enabled !== !1 && (o && (this.dispatchEvent({ type: "dragend", object: o }), o = null), this.domElement.style.cursor = i ? "pointer" : "auto", this.state = c.NONE);
|
|
@@ -2,11 +2,17 @@ import "../../../build/three.module.js";
|
|
|
2
2
|
import { Controls as c, Vector3 as n, Quaternion as h } from "../../../build/three.core.js";
|
|
3
3
|
const m = { type: "change" }, a = 1e-6, r = new h();
|
|
4
4
|
class b extends c {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Constructs a new controls instance.
|
|
7
|
+
*
|
|
8
|
+
* @param {Object3D} object - The object that is managed by the controls.
|
|
9
|
+
* @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
|
|
10
|
+
*/
|
|
11
|
+
constructor(o, t = null) {
|
|
12
|
+
super(o, t), this.movementSpeed = 1, this.rollSpeed = 5e-3, this.dragToLook = !1, this.autoForward = !1, this._moveState = { up: 0, down: 0, left: 0, right: 0, forward: 0, back: 0, pitchUp: 0, pitchDown: 0, yawLeft: 0, yawRight: 0, rollLeft: 0, rollRight: 0 }, this._moveVector = new n(0, 0, 0), this._rotationVector = new n(0, 0, 0), this._lastQuaternion = new h(), this._lastPosition = new n(), this._status = 0, this._onKeyDown = _.bind(this), this._onKeyUp = d.bind(this), this._onPointerMove = l.bind(this), this._onPointerDown = v.bind(this), this._onPointerUp = f.bind(this), this._onPointerCancel = p.bind(this), this._onContextMenu = w.bind(this), t !== null && this.connect(t);
|
|
7
13
|
}
|
|
8
|
-
connect() {
|
|
9
|
-
window.addEventListener("keydown", this._onKeyDown), window.addEventListener("keyup", this._onKeyUp), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointerup", this._onPointerUp), this.domElement.addEventListener("pointercancel", this._onPointerCancel), this.domElement.addEventListener("contextmenu", this._onContextMenu);
|
|
14
|
+
connect(o) {
|
|
15
|
+
super.connect(o), window.addEventListener("keydown", this._onKeyDown), window.addEventListener("keyup", this._onKeyUp), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointerup", this._onPointerUp), this.domElement.addEventListener("pointercancel", this._onPointerCancel), this.domElement.addEventListener("contextmenu", this._onContextMenu);
|
|
10
16
|
}
|
|
11
17
|
disconnect() {
|
|
12
18
|
window.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("keyup", this._onKeyUp), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerCancel), this.domElement.removeEventListener("contextmenu", this._onContextMenu);
|
|
@@ -16,8 +22,8 @@ class b extends c {
|
|
|
16
22
|
}
|
|
17
23
|
update(o) {
|
|
18
24
|
if (this.enabled === !1) return;
|
|
19
|
-
const
|
|
20
|
-
|
|
25
|
+
const t = this.object, i = o * this.movementSpeed, s = o * this.rollSpeed;
|
|
26
|
+
t.translateX(this._moveVector.x * i), t.translateY(this._moveVector.y * i), t.translateZ(this._moveVector.z * i), r.set(this._rotationVector.x * s, this._rotationVector.y * s, this._rotationVector.z * s, 1).normalize(), t.quaternion.multiply(r), (this._lastPosition.distanceToSquared(t.position) > a || 8 * (1 - this._lastQuaternion.dot(t.quaternion)) > a) && (this.dispatchEvent(m), this._lastQuaternion.copy(t.quaternion), this._lastPosition.copy(t.position));
|
|
21
27
|
}
|
|
22
28
|
// private
|
|
23
29
|
_updateMovementVector() {
|
|
@@ -37,9 +43,9 @@ class b extends c {
|
|
|
37
43
|
};
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
|
-
function _(
|
|
41
|
-
if (!(
|
|
42
|
-
switch (
|
|
46
|
+
function _(e) {
|
|
47
|
+
if (!(e.altKey || this.enabled === !1)) {
|
|
48
|
+
switch (e.code) {
|
|
43
49
|
case "ShiftLeft":
|
|
44
50
|
case "ShiftRight":
|
|
45
51
|
this.movementSpeedMultiplier = 0.1;
|
|
@@ -84,9 +90,9 @@ function _(t) {
|
|
|
84
90
|
this._updateMovementVector(), this._updateRotationVector();
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
|
-
function d(
|
|
93
|
+
function d(e) {
|
|
88
94
|
if (this.enabled !== !1) {
|
|
89
|
-
switch (
|
|
95
|
+
switch (e.code) {
|
|
90
96
|
case "ShiftLeft":
|
|
91
97
|
case "ShiftRight":
|
|
92
98
|
this.movementSpeedMultiplier = 1;
|
|
@@ -131,12 +137,12 @@ function d(t) {
|
|
|
131
137
|
this._updateMovementVector(), this._updateRotationVector();
|
|
132
138
|
}
|
|
133
139
|
}
|
|
134
|
-
function v(
|
|
140
|
+
function v(e) {
|
|
135
141
|
if (this.enabled !== !1)
|
|
136
142
|
if (this.dragToLook)
|
|
137
143
|
this._status++;
|
|
138
144
|
else {
|
|
139
|
-
switch (
|
|
145
|
+
switch (e.button) {
|
|
140
146
|
case 0:
|
|
141
147
|
this._moveState.forward = 1;
|
|
142
148
|
break;
|
|
@@ -147,18 +153,18 @@ function v(t) {
|
|
|
147
153
|
this._updateMovementVector();
|
|
148
154
|
}
|
|
149
155
|
}
|
|
150
|
-
function l(
|
|
156
|
+
function l(e) {
|
|
151
157
|
if (this.enabled !== !1 && (!this.dragToLook || this._status > 0)) {
|
|
152
|
-
const o = this._getContainerDimensions(),
|
|
153
|
-
this._moveState.yawLeft = -(
|
|
158
|
+
const o = this._getContainerDimensions(), t = o.size[0] / 2, i = o.size[1] / 2;
|
|
159
|
+
this._moveState.yawLeft = -(e.pageX - o.offset[0] - t) / t, this._moveState.pitchDown = (e.pageY - o.offset[1] - i) / i, this._updateRotationVector();
|
|
154
160
|
}
|
|
155
161
|
}
|
|
156
|
-
function f(
|
|
162
|
+
function f(e) {
|
|
157
163
|
if (this.enabled !== !1) {
|
|
158
164
|
if (this.dragToLook)
|
|
159
165
|
this._status--, this._moveState.yawLeft = this._moveState.pitchDown = 0;
|
|
160
166
|
else {
|
|
161
|
-
switch (
|
|
167
|
+
switch (e.button) {
|
|
162
168
|
case 0:
|
|
163
169
|
this._moveState.forward = 0;
|
|
164
170
|
break;
|
|
@@ -174,8 +180,8 @@ function f(t) {
|
|
|
174
180
|
function p() {
|
|
175
181
|
this.enabled !== !1 && (this.dragToLook ? (this._status = 0, this._moveState.yawLeft = this._moveState.pitchDown = 0) : (this._moveState.forward = 0, this._moveState.back = 0, this._updateMovementVector()), this._updateRotationVector());
|
|
176
182
|
}
|
|
177
|
-
function w(
|
|
178
|
-
this.enabled !== !1 &&
|
|
183
|
+
function w(e) {
|
|
184
|
+
this.enabled !== !1 && e.preventDefault();
|
|
179
185
|
}
|
|
180
186
|
export {
|
|
181
187
|
b as FlyControls
|
|
@@ -11,11 +11,17 @@ const D = { type: "change" }, b = { type: "start" }, M = { type: "end" }, f = ne
|
|
|
11
11
|
TOUCH_DOLLY_ROTATE: 6
|
|
12
12
|
}, y = 1e-6;
|
|
13
13
|
class v extends S {
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a new controls instance.
|
|
16
|
+
*
|
|
17
|
+
* @param {Object3D} object - The object that is managed by the controls.
|
|
18
|
+
* @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
|
|
19
|
+
*/
|
|
14
20
|
constructor(t, e = null) {
|
|
15
|
-
super(t, e), this.state = o.NONE, this.
|
|
21
|
+
super(t, e), this.state = o.NONE, this.target = new p(), this.cursor = new p(), 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: u.ROTATE, MIDDLE: u.DOLLY, RIGHT: u.PAN }, this.touches = { ONE: _.ROTATE, TWO: _.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new p(), this._lastQuaternion = new E(), this._lastTargetPosition = new p(), this._quat = new E().setFromUnitVectors(t.up, new p(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new P(), this._sphericalDelta = new P(), this._scale = 1, this._panOffset = new p(), this._rotateStart = new c(), this._rotateEnd = new c(), this._rotateDelta = new c(), this._panStart = new c(), this._panEnd = new c(), this._panDelta = new c(), this._dollyStart = new c(), this._dollyEnd = new c(), this._dollyDelta = new c(), this._dollyDirection = new p(), this._mouse = new c(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = L.bind(this), this._onPointerDown = A.bind(this), this._onPointerUp = k.bind(this), this._onContextMenu = Z.bind(this), this._onMouseWheel = N.bind(this), this._onKeyDown = Y.bind(this), this._onTouchStart = I.bind(this), this._onTouchMove = U.bind(this), this._onMouseDown = x.bind(this), this._onMouseMove = C.bind(this), this._interceptControlDown = z.bind(this), this._interceptControlUp = K.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
|
|
16
22
|
}
|
|
17
|
-
connect() {
|
|
18
|
-
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";
|
|
23
|
+
connect(t) {
|
|
24
|
+
super.connect(t), 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";
|
|
19
25
|
}
|
|
20
26
|
disconnect() {
|
|
21
27
|
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";
|
|
@@ -23,24 +29,55 @@ class v extends S {
|
|
|
23
29
|
dispose() {
|
|
24
30
|
this.disconnect();
|
|
25
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the current vertical rotation, in radians.
|
|
34
|
+
*
|
|
35
|
+
* @return {number} The current vertical rotation, in radians.
|
|
36
|
+
*/
|
|
26
37
|
getPolarAngle() {
|
|
27
38
|
return this._spherical.phi;
|
|
28
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the current horizontal rotation, in radians.
|
|
42
|
+
*
|
|
43
|
+
* @return {number} The current horizontal rotation, in radians.
|
|
44
|
+
*/
|
|
29
45
|
getAzimuthalAngle() {
|
|
30
46
|
return this._spherical.theta;
|
|
31
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns the distance from the camera to the target.
|
|
50
|
+
*
|
|
51
|
+
* @return {number} The distance from the camera to the target.
|
|
52
|
+
*/
|
|
32
53
|
getDistance() {
|
|
33
54
|
return this.object.position.distanceTo(this.target);
|
|
34
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Adds key event listeners to the given DOM element.
|
|
58
|
+
* `window` is a recommended argument for using this method.
|
|
59
|
+
*
|
|
60
|
+
* @param {HTMLDOMElement} domElement - The DOM element
|
|
61
|
+
*/
|
|
35
62
|
listenToKeyEvents(t) {
|
|
36
63
|
t.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = t;
|
|
37
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Removes the key event listener previously defined with `listenToKeyEvents()`.
|
|
67
|
+
*/
|
|
38
68
|
stopListenToKeyEvents() {
|
|
39
69
|
this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
|
|
40
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Save the current state of the controls. This can later be recovered with `reset()`.
|
|
73
|
+
*/
|
|
41
74
|
saveState() {
|
|
42
75
|
this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
|
|
43
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Reset the controls to their state from either the last time the `saveState()`
|
|
79
|
+
* was called, or the initial state.
|
|
80
|
+
*/
|
|
44
81
|
reset() {
|
|
45
82
|
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(D), this.update(), this.state = o.NONE;
|
|
46
83
|
}
|
|
@@ -154,16 +191,16 @@ class v extends S {
|
|
|
154
191
|
let e = !1;
|
|
155
192
|
switch (t.code) {
|
|
156
193
|
case this.keys.UP:
|
|
157
|
-
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(r * this.
|
|
194
|
+
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(r * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), e = !0;
|
|
158
195
|
break;
|
|
159
196
|
case this.keys.BOTTOM:
|
|
160
|
-
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(-r * this.
|
|
197
|
+
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(-r * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), e = !0;
|
|
161
198
|
break;
|
|
162
199
|
case this.keys.LEFT:
|
|
163
|
-
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(r * this.
|
|
200
|
+
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(r * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), e = !0;
|
|
164
201
|
break;
|
|
165
202
|
case this.keys.RIGHT:
|
|
166
|
-
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(-r * this.
|
|
203
|
+
t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(-r * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), e = !0;
|
|
167
204
|
break;
|
|
168
205
|
}
|
|
169
206
|
e && (t.preventDefault(), this.update());
|
|
@@ -275,7 +312,7 @@ function A(i) {
|
|
|
275
312
|
function L(i) {
|
|
276
313
|
this.enabled !== !1 && (i.pointerType === "touch" ? this._onTouchMove(i) : this._onMouseMove(i));
|
|
277
314
|
}
|
|
278
|
-
function
|
|
315
|
+
function k(i) {
|
|
279
316
|
switch (this._removePointer(i), this._pointers.length) {
|
|
280
317
|
case 0:
|
|
281
318
|
this.domElement.releasePointerCapture(i.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(M), this.state = o.NONE;
|
|
@@ -286,7 +323,7 @@ function x(i) {
|
|
|
286
323
|
break;
|
|
287
324
|
}
|
|
288
325
|
}
|
|
289
|
-
function
|
|
326
|
+
function x(i) {
|
|
290
327
|
let t;
|
|
291
328
|
switch (i.button) {
|
|
292
329
|
case 0:
|
|
@@ -329,7 +366,7 @@ function C(i) {
|
|
|
329
366
|
}
|
|
330
367
|
this.state !== o.NONE && this.dispatchEvent(b);
|
|
331
368
|
}
|
|
332
|
-
function
|
|
369
|
+
function C(i) {
|
|
333
370
|
switch (this.state) {
|
|
334
371
|
case o.ROTATE:
|
|
335
372
|
if (this.enableRotate === !1) return;
|
|
@@ -2,16 +2,22 @@ import "../../../build/three.module.js";
|
|
|
2
2
|
import { Controls as O, MOUSE as r, Vector3 as o, Vector2 as n, Quaternion as S, MathUtils as f } from "../../../build/three.core.js";
|
|
3
3
|
const u = { type: "change" }, E = { type: "start" }, b = { type: "end" }, P = 1e-6, s = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 }, p = new n(), h = new n(), M = new o(), _ = new o(), y = new o(), a = new S(), w = new o(), m = new o(), g = new o(), l = new o();
|
|
4
4
|
class K extends O {
|
|
5
|
+
/**
|
|
6
|
+
* Constructs a new controls instance.
|
|
7
|
+
*
|
|
8
|
+
* @param {Object3D} object - The object that is managed by the controls.
|
|
9
|
+
* @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
|
|
10
|
+
*/
|
|
5
11
|
constructor(t, i = null) {
|
|
6
|
-
super(t, i), this.
|
|
12
|
+
super(t, i), this.screen = { left: 0, top: 0, width: 0, height: 0 }, this.rotateSpeed = 1, this.zoomSpeed = 1.2, this.panSpeed = 0.3, this.noRotate = !1, this.noZoom = !1, this.noPan = !1, this.staticMoving = !1, this.dynamicDampingFactor = 0.2, this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.keys = [
|
|
7
13
|
"KeyA",
|
|
8
14
|
"KeyS",
|
|
9
15
|
"KeyD"
|
|
10
16
|
/*D*/
|
|
11
|
-
], this.mouseButtons = { LEFT: r.ROTATE, MIDDLE: r.DOLLY, RIGHT: r.PAN }, this.
|
|
17
|
+
], this.mouseButtons = { LEFT: r.ROTATE, MIDDLE: r.DOLLY, RIGHT: r.PAN }, this.target = new o(), this.state = s.NONE, this.keyState = s.NONE, this._lastPosition = new o(), this._lastZoom = 1, this._touchZoomDistanceStart = 0, this._touchZoomDistanceEnd = 0, this._lastAngle = 0, this._eye = new o(), this._movePrev = new n(), this._moveCurr = new n(), this._lastAxis = new o(), this._zoomStart = new n(), this._zoomEnd = new n(), this._panStart = new n(), this._panEnd = new n(), this._pointers = [], this._pointerPositions = {}, this._onPointerMove = j.bind(this), this._onPointerDown = C.bind(this), this._onPointerUp = T.bind(this), this._onPointerCancel = k.bind(this), this._onContextMenu = L.bind(this), this._onMouseWheel = N.bind(this), this._onKeyDown = z.bind(this), this._onKeyUp = D.bind(this), this._onTouchStart = U.bind(this), this._onTouchMove = R.bind(this), this._onTouchEnd = Y.bind(this), this._onMouseDown = A.bind(this), this._onMouseMove = x.bind(this), this._onMouseUp = Z.bind(this), this._target0 = this.target.clone(), this._position0 = this.object.position.clone(), this._up0 = this.object.up.clone(), this._zoom0 = this.object.zoom, i !== null && (this.connect(i), this.handleResize()), this.update();
|
|
12
18
|
}
|
|
13
|
-
connect() {
|
|
14
|
-
window.addEventListener("keydown", this._onKeyDown), window.addEventListener("keyup", this._onKeyUp), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerCancel), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "none";
|
|
19
|
+
connect(t) {
|
|
20
|
+
super.connect(t), window.addEventListener("keydown", this._onKeyDown), window.addEventListener("keyup", this._onKeyUp), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerCancel), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "none";
|
|
15
21
|
}
|
|
16
22
|
disconnect() {
|
|
17
23
|
window.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("keyup", this._onKeyUp), this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerCancel), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "auto";
|
|
@@ -19,6 +25,9 @@ class K extends O {
|
|
|
19
25
|
dispose() {
|
|
20
26
|
this.disconnect();
|
|
21
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Must be called if the application window is resized.
|
|
30
|
+
*/
|
|
22
31
|
handleResize() {
|
|
23
32
|
const t = this.domElement.getBoundingClientRect(), i = this.domElement.ownerDocument.documentElement;
|
|
24
33
|
this.screen.left = t.left + window.pageXOffset - i.clientLeft, this.screen.top = t.top + window.pageYOffset - i.clientTop, this.screen.width = t.width, this.screen.height = t.height;
|
|
@@ -26,6 +35,9 @@ class K extends O {
|
|
|
26
35
|
update() {
|
|
27
36
|
this._eye.subVectors(this.object.position, this.target), this.noRotate || this._rotateCamera(), this.noZoom || this._zoomCamera(), this.noPan || this._panCamera(), this.object.position.addVectors(this.target, this._eye), this.object.isPerspectiveCamera ? (this._checkDistances(), this.object.lookAt(this.target), this._lastPosition.distanceToSquared(this.object.position) > P && (this.dispatchEvent(u), this._lastPosition.copy(this.object.position))) : this.object.isOrthographicCamera ? (this.object.lookAt(this.target), (this._lastPosition.distanceToSquared(this.object.position) > P || this._lastZoom !== this.object.zoom) && (this.dispatchEvent(u), this._lastPosition.copy(this.object.position), this._lastZoom = this.object.zoom)) : console.warn("THREE.TrackballControls: Unsupported camera type.");
|
|
28
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Resets the controls to its initial state.
|
|
40
|
+
*/
|
|
29
41
|
reset() {
|
|
30
42
|
this.state = s.NONE, this.keyState = s.NONE, this.target.copy(this._target0), this.object.position.copy(this._position0), this.object.up.copy(this._up0), this.object.zoom = this._zoom0, this.object.updateProjectionMatrix(), this._eye.subVectors(this.object.position, this.target), this.object.lookAt(this.target), this.dispatchEvent(u), this._lastPosition.copy(this.object.position), this._lastZoom = this.object.zoom;
|
|
31
43
|
}
|
|
@@ -4,6 +4,14 @@ import { ShaderPass as p } from "./ShaderPass.js";
|
|
|
4
4
|
import { MaskPass as a, ClearMaskPass as l } from "./MaskPass.js";
|
|
5
5
|
import { Vector2 as o, WebGLRenderTarget as c, HalfFloatType as g, NoBlending as _, Clock as u } from "../../../build/three.core.js";
|
|
6
6
|
class P {
|
|
7
|
+
/**
|
|
8
|
+
* Constructs a new effect composer.
|
|
9
|
+
*
|
|
10
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
11
|
+
* @param {WebGLRenderTarget} [renderTarget] - This render target and a clone will
|
|
12
|
+
* be used as the internal read and write buffers. If not given, the composer creates
|
|
13
|
+
* the buffers automatically.
|
|
14
|
+
*/
|
|
7
15
|
constructor(e, t) {
|
|
8
16
|
if (this.renderer = e, this._pixelRatio = e.getPixelRatio(), t === void 0) {
|
|
9
17
|
const s = e.getSize(new o());
|
|
@@ -12,26 +20,57 @@ class P {
|
|
|
12
20
|
this._width = t.width, this._height = t.height;
|
|
13
21
|
this.renderTarget1 = t, this.renderTarget2 = t.clone(), this.renderTarget2.texture.name = "EffectComposer.rt2", this.writeBuffer = this.renderTarget1, this.readBuffer = this.renderTarget2, this.renderToScreen = !0, this.passes = [], this.copyPass = new p(d), this.copyPass.material.blending = _, this.clock = new u();
|
|
14
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Swaps the internal read/write buffers.
|
|
25
|
+
*/
|
|
15
26
|
swapBuffers() {
|
|
16
27
|
const e = this.readBuffer;
|
|
17
28
|
this.readBuffer = this.writeBuffer, this.writeBuffer = e;
|
|
18
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Adds the given pass to the pass chain.
|
|
32
|
+
*
|
|
33
|
+
* @param {Pass} pass - The pass to add.
|
|
34
|
+
*/
|
|
19
35
|
addPass(e) {
|
|
20
36
|
this.passes.push(e), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
|
|
21
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Inserts the given pass at a given index.
|
|
40
|
+
*
|
|
41
|
+
* @param {Pass} pass - The pass to insert.
|
|
42
|
+
* @param {number} index - The index into the pass chain.
|
|
43
|
+
*/
|
|
22
44
|
insertPass(e, t) {
|
|
23
45
|
this.passes.splice(t, 0, e), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
|
|
24
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Removes the given pass from the pass chain.
|
|
49
|
+
*
|
|
50
|
+
* @param {Pass} pass - The pass to remove.
|
|
51
|
+
*/
|
|
25
52
|
removePass(e) {
|
|
26
53
|
const t = this.passes.indexOf(e);
|
|
27
54
|
t !== -1 && this.passes.splice(t, 1);
|
|
28
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns `true` if the pass for the given index is the last enabled pass in the pass chain.
|
|
58
|
+
*
|
|
59
|
+
* @param {number} passIndex - The pass index.
|
|
60
|
+
* @return {boolean} Whether the pass for the given index is the last pass in the pass chain.
|
|
61
|
+
*/
|
|
29
62
|
isLastEnabledPass(e) {
|
|
30
63
|
for (let t = e + 1; t < this.passes.length; t++)
|
|
31
64
|
if (this.passes[t].enabled)
|
|
32
65
|
return !1;
|
|
33
66
|
return !0;
|
|
34
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Executes all enabled post-processing passes in order to produce the final frame.
|
|
70
|
+
*
|
|
71
|
+
* @param {number} deltaTime - The delta time in seconds. If not given, the composer computes
|
|
72
|
+
* its own time delta value.
|
|
73
|
+
*/
|
|
35
74
|
render(e) {
|
|
36
75
|
e === void 0 && (e = this.clock.getDelta());
|
|
37
76
|
const t = this.renderer.getRenderTarget();
|
|
@@ -51,6 +90,12 @@ class P {
|
|
|
51
90
|
}
|
|
52
91
|
this.renderer.setRenderTarget(t);
|
|
53
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Resets the internal state of the EffectComposer.
|
|
95
|
+
*
|
|
96
|
+
* @param {WebGLRenderTarget} [renderTarget] - This render target has the same purpose like
|
|
97
|
+
* the one from the constructor. If set, it is used to setup the read and write buffers.
|
|
98
|
+
*/
|
|
54
99
|
reset(e) {
|
|
55
100
|
if (e === void 0) {
|
|
56
101
|
const t = this.renderer.getSize(new o());
|
|
@@ -58,6 +103,13 @@ class P {
|
|
|
58
103
|
}
|
|
59
104
|
this.renderTarget1.dispose(), this.renderTarget2.dispose(), this.renderTarget1 = e, this.renderTarget2 = e.clone(), this.writeBuffer = this.renderTarget1, this.readBuffer = this.renderTarget2;
|
|
60
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Resizes the internal read and write buffers as well as all passes. Similar to {@link WebGLRenderer#setSize},
|
|
108
|
+
* this method honors the current pixel ration.
|
|
109
|
+
*
|
|
110
|
+
* @param {number} width - The width in logical pixels.
|
|
111
|
+
* @param {number} height - The height in logical pixels.
|
|
112
|
+
*/
|
|
61
113
|
setSize(e, t) {
|
|
62
114
|
this._width = e, this._height = t;
|
|
63
115
|
const s = this._width * this._pixelRatio, i = this._height * this._pixelRatio;
|
|
@@ -65,9 +117,19 @@ class P {
|
|
|
65
117
|
for (let r = 0; r < this.passes.length; r++)
|
|
66
118
|
this.passes[r].setSize(s, i);
|
|
67
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Sets device pixel ratio. This is usually used for HiDPI device to prevent blurring output.
|
|
122
|
+
* Setting the pixel ratio will automatically resize the composer.
|
|
123
|
+
*
|
|
124
|
+
* @param {number} pixelRatio - The pixel ratio to set.
|
|
125
|
+
*/
|
|
68
126
|
setPixelRatio(e) {
|
|
69
127
|
this._pixelRatio = e, this.setSize(this._width, this._height);
|
|
70
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Frees the GPU-related resources allocated by this instance. Call this
|
|
131
|
+
* method whenever the composer is no longer used in your app.
|
|
132
|
+
*/
|
|
71
133
|
dispose() {
|
|
72
134
|
this.renderTarget1.dispose(), this.renderTarget2.dispose(), this.copyPass.dispose();
|
|
73
135
|
}
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { Pass as r } from "./Pass.js";
|
|
2
2
|
class o extends r {
|
|
3
|
+
/**
|
|
4
|
+
* Constructs a new mask pass.
|
|
5
|
+
*
|
|
6
|
+
* @param {Scene} scene - The 3D objects in this scene will define the mask.
|
|
7
|
+
* @param {Camera} camera - The camera.
|
|
8
|
+
*/
|
|
3
9
|
constructor(s, f) {
|
|
4
10
|
super(), this.scene = s, this.camera = f, this.clear = !0, this.needsSwap = !1, this.inverse = !1;
|
|
5
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Performs a mask pass with the configured scene and camera.
|
|
14
|
+
*
|
|
15
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
16
|
+
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
|
17
|
+
* destination for the pass.
|
|
18
|
+
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
|
19
|
+
* previous pass from this buffer.
|
|
20
|
+
* @param {number} deltaTime - The delta time in seconds.
|
|
21
|
+
* @param {boolean} maskActive - Whether masking is active or not.
|
|
22
|
+
*/
|
|
6
23
|
render(s, f, u) {
|
|
7
24
|
const t = s.getContext(), e = s.state;
|
|
8
25
|
e.buffers.color.setMask(!1), e.buffers.depth.setMask(!1), e.buffers.color.setLocked(!0), e.buffers.depth.setLocked(!0);
|
|
@@ -11,9 +28,23 @@ class o extends r {
|
|
|
11
28
|
}
|
|
12
29
|
}
|
|
13
30
|
class n extends r {
|
|
31
|
+
/**
|
|
32
|
+
* Constructs a new clear mask pass.
|
|
33
|
+
*/
|
|
14
34
|
constructor() {
|
|
15
35
|
super(), this.needsSwap = !1;
|
|
16
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Performs the clear of the currently defined mask.
|
|
39
|
+
*
|
|
40
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
41
|
+
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
|
42
|
+
* destination for the pass.
|
|
43
|
+
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
|
44
|
+
* previous pass from this buffer.
|
|
45
|
+
* @param {number} deltaTime - The delta time in seconds.
|
|
46
|
+
* @param {boolean} maskActive - Whether masking is active or not.
|
|
47
|
+
*/
|
|
17
48
|
render(s) {
|
|
18
49
|
s.state.buffers.stencil.setLocked(!1), s.state.buffers.stencil.setTest(!1);
|
|
19
50
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import "../../../build/three.module.js";
|
|
2
|
+
import { Mesh as r, OrthographicCamera as i, BufferGeometry as a, Float32BufferAttribute as t } from "../../../build/three.core.js";
|
|
3
|
+
class c {
|
|
4
|
+
/**
|
|
5
|
+
* Constructs a new pass.
|
|
6
|
+
*/
|
|
7
|
+
constructor() {
|
|
8
|
+
this.isPass = !0, this.enabled = !0, this.needsSwap = !0, this.clear = !1, this.renderToScreen = !1;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Sets the size of the pass.
|
|
12
|
+
*
|
|
13
|
+
* @abstract
|
|
14
|
+
* @param {number} width - The width to set.
|
|
15
|
+
* @param {number} height - The height to set.
|
|
16
|
+
*/
|
|
17
|
+
setSize() {
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* This method holds the render logic of a pass. It must be implemented in all derived classes.
|
|
21
|
+
*
|
|
22
|
+
* @abstract
|
|
23
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
24
|
+
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
|
25
|
+
* destination for the pass.
|
|
26
|
+
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
|
27
|
+
* previous pass from this buffer.
|
|
28
|
+
* @param {number} deltaTime - The delta time in seconds.
|
|
29
|
+
* @param {boolean} maskActive - Whether masking is active or not.
|
|
30
|
+
*/
|
|
31
|
+
render() {
|
|
32
|
+
console.error("THREE.Pass: .render() must be implemented in derived pass.");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Frees the GPU-related resources allocated by this instance. Call this
|
|
36
|
+
* method whenever the pass is no longer used in your app.
|
|
37
|
+
*
|
|
38
|
+
* @abstract
|
|
39
|
+
*/
|
|
40
|
+
dispose() {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const n = new i(-1, 1, 1, -1, 0, 1);
|
|
44
|
+
class o extends a {
|
|
45
|
+
constructor() {
|
|
46
|
+
super(), this.setAttribute("position", new t([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3)), this.setAttribute("uv", new t([0, 2, 0, 0, 2, 0], 2));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const m = new o();
|
|
50
|
+
class u {
|
|
51
|
+
/**
|
|
52
|
+
* Constructs a new full screen quad.
|
|
53
|
+
*
|
|
54
|
+
* @param {?Material} material - The material to render te full screen quad with.
|
|
55
|
+
*/
|
|
56
|
+
constructor(e) {
|
|
57
|
+
this._mesh = new r(m, e);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Frees the GPU-related resources allocated by this instance. Call this
|
|
61
|
+
* method whenever the instance is no longer used in your app.
|
|
62
|
+
*/
|
|
63
|
+
dispose() {
|
|
64
|
+
this._mesh.geometry.dispose();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Renders the full screen quad.
|
|
68
|
+
*
|
|
69
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
70
|
+
*/
|
|
71
|
+
render(e) {
|
|
72
|
+
e.render(this._mesh, n);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The quad's material.
|
|
76
|
+
*
|
|
77
|
+
* @type {?Material}
|
|
78
|
+
*/
|
|
79
|
+
get material() {
|
|
80
|
+
return this._mesh.material;
|
|
81
|
+
}
|
|
82
|
+
set material(e) {
|
|
83
|
+
this._mesh.material = e;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
u as FullScreenQuad,
|
|
88
|
+
c as Pass
|
|
89
|
+
};
|
|
@@ -2,9 +2,30 @@ import "../../../build/three.module.js";
|
|
|
2
2
|
import { Pass as s } from "./Pass.js";
|
|
3
3
|
import { Color as r } from "../../../build/three.core.js";
|
|
4
4
|
class p extends s {
|
|
5
|
+
/**
|
|
6
|
+
* Constructs a new render pass.
|
|
7
|
+
*
|
|
8
|
+
* @param {Scene} scene - The scene to render.
|
|
9
|
+
* @param {Camera} camera - The camera.
|
|
10
|
+
* @param {?Material} [overrideMaterial=null] - The override material. If set, this material is used
|
|
11
|
+
* for all objects in the scene.
|
|
12
|
+
* @param {?(number|Color|string)} [clearColor=null] - The clear color of the render pass.
|
|
13
|
+
* @param {?number} [clearAlpha=null] - The clear alpha of the render pass.
|
|
14
|
+
*/
|
|
5
15
|
constructor(l, i, t = null, e = null, a = null) {
|
|
6
16
|
super(), this.scene = l, this.camera = i, this.overrideMaterial = t, this.clearColor = e, this.clearAlpha = a, this.clear = !0, this.clearDepth = !1, this.needsSwap = !1, this._oldClearColor = new r();
|
|
7
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Performs a beauty pass with the configured scene and camera.
|
|
20
|
+
*
|
|
21
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
22
|
+
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
|
23
|
+
* destination for the pass.
|
|
24
|
+
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
|
25
|
+
* previous pass from this buffer.
|
|
26
|
+
* @param {number} deltaTime - The delta time in seconds.
|
|
27
|
+
* @param {boolean} maskActive - Whether masking is active or not.
|
|
28
|
+
*/
|
|
8
29
|
render(l, i, t) {
|
|
9
30
|
const e = l.autoClear;
|
|
10
31
|
l.autoClear = !1;
|