@anov/3d 0.0.287 → 0.0.289
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/anov3d.js +40 -43
- package/dist/anov3d.js.map +1 -1
- package/dist/applicationApi.js +94 -118
- package/dist/applicationApi.js.map +1 -1
- package/dist/hooksManager.js +10 -10
- package/dist/hooksManager.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/messageStatus.js +3 -3
- package/dist/messageStatus.js.map +1 -1
- package/dist/module/animation/index.js +61 -113
- package/dist/module/animation/index.js.map +1 -1
- package/dist/module/animation/motion/index.js +58 -91
- package/dist/module/animation/motion/index.js.map +1 -1
- package/dist/module/animation/strategy.js +7 -21
- package/dist/module/animation/strategy.js.map +1 -1
- package/dist/module/camera/index.js +216 -278
- package/dist/module/camera/index.js.map +1 -1
- package/dist/module/develop/index.js +27 -35
- package/dist/module/develop/index.js.map +1 -1
- package/dist/module/entity/area/index.js +29 -87
- package/dist/module/entity/area/index.js.map +1 -1
- package/dist/module/entity/bar/index.js +5 -24
- package/dist/module/entity/bar/index.js.map +1 -1
- package/dist/module/entity/bar/style/bar_01.js +13 -52
- package/dist/module/entity/bar/style/bar_01.js.map +1 -1
- package/dist/module/entity/bar/style/index.js +7 -21
- package/dist/module/entity/bar/style/index.js.map +1 -1
- package/dist/module/entity/baseEntity.js +43 -66
- package/dist/module/entity/baseEntity.js.map +1 -1
- package/dist/module/entity/batch/index.js +77 -168
- package/dist/module/entity/batch/index.js.map +1 -1
- package/dist/module/entity/dispose.js +14 -16
- package/dist/module/entity/dispose.js.map +1 -1
- package/dist/module/entity/flyline/index.js +34 -90
- package/dist/module/entity/flyline/index.js.map +1 -1
- package/dist/module/entity/group/index.js +59 -75
- package/dist/module/entity/group/index.js.map +1 -1
- package/dist/module/entity/heatmap/index.js +62 -79
- package/dist/module/entity/heatmap/index.js.map +1 -1
- package/dist/module/entity/hybridList.js +49 -67
- package/dist/module/entity/hybridList.js.map +1 -1
- package/dist/module/entity/index.js +442 -644
- package/dist/module/entity/index.js.map +1 -1
- package/dist/module/entity/infoPanel/index.js +23 -76
- package/dist/module/entity/infoPanel/index.js.map +1 -1
- package/dist/module/entity/light/pointLight/index.js +48 -84
- package/dist/module/entity/light/pointLight/index.js.map +1 -1
- package/dist/module/entity/mark/index.js +51 -101
- package/dist/module/entity/mark/index.js.map +1 -1
- package/dist/module/entity/model/index.js +108 -151
- package/dist/module/entity/model/index.js.map +1 -1
- package/dist/module/entity/model/load/loadFbx.js +8 -8
- package/dist/module/entity/model/load/loadFbx.js.map +1 -1
- package/dist/module/entity/model/load/loadGlb.js +13 -11
- package/dist/module/entity/model/load/loadGlb.js.map +1 -1
- package/dist/module/entity/model/load.js +19 -57
- package/dist/module/entity/model/load.js.map +1 -1
- package/dist/module/entity/poi/index.js +34 -90
- package/dist/module/entity/poi/index.js.map +1 -1
- package/dist/module/entity/shape/index.js +67 -136
- package/dist/module/entity/shape/index.js.map +1 -1
- package/dist/module/entity/spline/index.js +22 -75
- package/dist/module/entity/spline/index.js.map +1 -1
- package/dist/module/entity/strategy.js +92 -274
- package/dist/module/entity/strategy.js.map +1 -1
- package/dist/module/entity/traffic/realismTraffic/index.js +59 -88
- package/dist/module/entity/traffic/realismTraffic/index.js.map +1 -1
- package/dist/module/entity/traffic/streamerTraffic/index.js +50 -81
- package/dist/module/entity/traffic/streamerTraffic/index.js.map +1 -1
- package/dist/module/entity/utils.js +11 -13
- package/dist/module/entity/utils.js.map +1 -1
- package/dist/module/entity/videoPanel/index.js +23 -76
- package/dist/module/entity/videoPanel/index.js.map +1 -1
- package/dist/module/environment/index.js +54 -73
- package/dist/module/environment/index.js.map +1 -1
- package/dist/module/environment/season/index.js +342 -184
- package/dist/module/environment/season/index.js.map +1 -1
- package/dist/module/eventBus/entityEvents.js +1 -1
- package/dist/module/eventBus/entityEvents.js.map +1 -1
- package/dist/module/eventBus/index.js +79 -93
- package/dist/module/eventBus/index.js.map +1 -1
- package/dist/module/material/index.js +279 -334
- package/dist/module/material/index.js.map +1 -1
- package/dist/module/scene/fileParse.js +276 -369
- package/dist/module/scene/fileParse.js.map +1 -1
- package/dist/module/scene/index.js +106 -161
- package/dist/module/scene/index.js.map +1 -1
- package/dist/module/tool/index.js +26 -33
- package/dist/module/tool/index.js.map +1 -1
- package/dist/sdkEntry.js +2 -23
- package/dist/sdkEntry.js.map +1 -1
- package/dist/utils/abstract.js +12 -15
- package/dist/utils/abstract.js.map +1 -1
- package/dist/utils/index.js +23 -24
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/messageFn.js +17 -18
- package/dist/utils/messageFn.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
1
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
2
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
7
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
12
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
8
|
import { Box3, MathUtils, Vector3 } from '@anov/3d-core';
|
|
14
9
|
import { PerspectiveCameraExpand as CameraExpand } from '@anov/3d-ability';
|
|
15
10
|
import StateMachine from 'javascript-state-machine';
|
|
16
11
|
import { MessageType, sendToMessage } from "../../utils/messageFn";
|
|
17
12
|
import { EMessageStatus } from "../../messageStatus";
|
|
18
13
|
import { hybridList } from "../entity";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _this = this;
|
|
22
|
-
_classCallCheck(this, Camera);
|
|
14
|
+
class Camera {
|
|
15
|
+
constructor(app) {
|
|
23
16
|
_defineProperty(this, "app", void 0);
|
|
24
17
|
_defineProperty(this, "camera", void 0);
|
|
25
18
|
_defineProperty(this, "controls", void 0);
|
|
@@ -30,15 +23,15 @@ var Camera = /*#__PURE__*/function () {
|
|
|
30
23
|
this.camera = app.sceneControl.camera;
|
|
31
24
|
this.controls = app.sceneControl.controls;
|
|
32
25
|
this.cameraUtils = new CameraExpand(this.camera, this.controls, app.sceneControl);
|
|
33
|
-
this.cameraUtils.addEventListener('change',
|
|
34
|
-
if (
|
|
26
|
+
this.cameraUtils.addEventListener('change', () => {
|
|
27
|
+
if (this.cameraUtils.isTransitionPeriod && this.isTrigger) {
|
|
35
28
|
sendToMessage({
|
|
36
29
|
messageType: MessageType.Event,
|
|
37
30
|
messageName: 'onCameraChanged',
|
|
38
31
|
status: EMessageStatus.Success
|
|
39
32
|
}, {
|
|
40
|
-
position:
|
|
41
|
-
target:
|
|
33
|
+
position: this.camera.position.toArray(),
|
|
34
|
+
target: this.controls.target.toArray()
|
|
42
35
|
});
|
|
43
36
|
}
|
|
44
37
|
});
|
|
@@ -48,279 +41,224 @@ var Camera = /*#__PURE__*/function () {
|
|
|
48
41
|
* focus camera
|
|
49
42
|
* @param params
|
|
50
43
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
entity = hybridList.get(point);
|
|
67
|
-
if (entity) {
|
|
68
|
-
_context.next = 7;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
throw new Error("entity ".concat(target, " not found"));
|
|
72
|
-
case 7:
|
|
73
|
-
entity.updateMatrixWorld();
|
|
74
|
-
box = new Box3().setFromObject(entity);
|
|
75
|
-
point = [new Vector3(box.min.x, box.min.y, box.min.z).toArray(), new Vector3(box.min.x, box.min.y, box.max.z).toArray(), new Vector3(box.min.x, box.max.y, box.min.z).toArray(), new Vector3(box.min.x, box.max.y, box.max.z).toArray(), new Vector3(box.max.x, box.min.y, box.min.z).toArray(), new Vector3(box.max.x, box.min.y, box.max.z).toArray(), new Vector3(box.max.x, box.max.y, box.min.z).toArray(), new Vector3(box.max.x, box.max.y, box.max.z).toArray()];
|
|
76
|
-
case 10:
|
|
77
|
-
_context.next = 12;
|
|
78
|
-
return this.cameraUtils.focus(_objectSpread(_objectSpread({}, params), {}, {
|
|
79
|
-
target: point
|
|
80
|
-
}));
|
|
81
|
-
case 12:
|
|
82
|
-
return _context.abrupt("return", _context.sent);
|
|
83
|
-
case 13:
|
|
84
|
-
case "end":
|
|
85
|
-
return _context.stop();
|
|
86
|
-
}
|
|
87
|
-
}, _callee, this);
|
|
88
|
-
}));
|
|
89
|
-
function focus(_x) {
|
|
90
|
-
return _focus.apply(this, arguments);
|
|
44
|
+
focus(params) {
|
|
45
|
+
var _this = this;
|
|
46
|
+
return _asyncToGenerator(function* () {
|
|
47
|
+
const {
|
|
48
|
+
target,
|
|
49
|
+
isTrigger = true
|
|
50
|
+
} = params;
|
|
51
|
+
let point = target;
|
|
52
|
+
_this.isTrigger = isTrigger;
|
|
53
|
+
if (typeof point === 'string') {
|
|
54
|
+
const entity = hybridList.get(point);
|
|
55
|
+
if (!entity) throw new Error(`entity ${target} not found`);
|
|
56
|
+
entity.updateMatrixWorld();
|
|
57
|
+
const box = new Box3().setFromObject(entity);
|
|
58
|
+
point = [new Vector3(box.min.x, box.min.y, box.min.z).toArray(), new Vector3(box.min.x, box.min.y, box.max.z).toArray(), new Vector3(box.min.x, box.max.y, box.min.z).toArray(), new Vector3(box.min.x, box.max.y, box.max.z).toArray(), new Vector3(box.max.x, box.min.y, box.min.z).toArray(), new Vector3(box.max.x, box.min.y, box.max.z).toArray(), new Vector3(box.max.x, box.max.y, box.min.z).toArray(), new Vector3(box.max.x, box.max.y, box.max.z).toArray()];
|
|
91
59
|
}
|
|
92
|
-
return focus
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
)
|
|
98
|
-
}, {
|
|
99
|
-
key: "setCameraMode",
|
|
100
|
-
value: function setCameraMode() {
|
|
101
|
-
// now only support orbit mode, so now do nothing
|
|
102
|
-
}
|
|
60
|
+
return yield _this.cameraUtils.focus(_objectSpread(_objectSpread({}, params), {}, {
|
|
61
|
+
target: point
|
|
62
|
+
}));
|
|
63
|
+
})();
|
|
64
|
+
}
|
|
103
65
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
var fov = baseParams.fov;
|
|
111
|
-
this.camera.fov = fov;
|
|
112
|
-
}
|
|
66
|
+
/**
|
|
67
|
+
* set camera mode, example:free、orbit、firstPerson
|
|
68
|
+
*/
|
|
69
|
+
setCameraMode() {
|
|
70
|
+
// now only support orbit mode, so now do nothing
|
|
71
|
+
}
|
|
113
72
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
yawLimit = params.yawLimit,
|
|
124
|
-
distanceLimit = params.distanceLimit;
|
|
125
|
-
distanceLimit && (this.controls.minDistance = distanceLimit[0]);
|
|
126
|
-
distanceLimit && (this.controls.maxDistance = (_ = distanceLimit[1]) !== null && _ !== void 0 ? _ : distanceLimit[0]);
|
|
73
|
+
/**
|
|
74
|
+
* set camera base option, example:fov
|
|
75
|
+
*/
|
|
76
|
+
setCameraOption(baseParams) {
|
|
77
|
+
const {
|
|
78
|
+
fov
|
|
79
|
+
} = baseParams;
|
|
80
|
+
this.camera.fov = fov;
|
|
81
|
+
}
|
|
127
82
|
|
|
128
|
-
|
|
83
|
+
/**
|
|
84
|
+
* set camera limit option, example:pitchLimit、yawLimit、distanceLimit
|
|
85
|
+
* @param params
|
|
86
|
+
*/
|
|
87
|
+
setCameraLimitOption(params) {
|
|
88
|
+
var _, _2, _3;
|
|
89
|
+
const {
|
|
90
|
+
pitchLimit,
|
|
91
|
+
yawLimit,
|
|
92
|
+
distanceLimit
|
|
93
|
+
} = params;
|
|
94
|
+
distanceLimit && (this.controls.minDistance = distanceLimit[0]);
|
|
95
|
+
distanceLimit && (this.controls.maxDistance = (_ = distanceLimit[1]) !== null && _ !== void 0 ? _ : distanceLimit[0]);
|
|
129
96
|
|
|
130
|
-
|
|
131
|
-
pitchLimit && (this.controls.maxPolarAngle = MathUtils.degToRad((_2 = pitchLimit[1]) !== null && _2 !== void 0 ? _2 : pitchLimit[0]));
|
|
132
|
-
yawLimit && (this.controls.minAzimuthAngle = MathUtils.degToRad(yawLimit[0]));
|
|
133
|
-
yawLimit && (this.controls.maxAzimuthAngle = MathUtils.degToRad((_3 = yawLimit[1]) !== null && _3 !== void 0 ? _3 : yawLimit[0]));
|
|
134
|
-
}
|
|
97
|
+
// TODO: 不能使用控制器的相关参数控制,需要与游戏引擎保持一致
|
|
135
98
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
value: function setCameraPosition(position) {
|
|
142
|
-
this.camera.position.copy(new Vector3().fromArray(position));
|
|
143
|
-
}
|
|
99
|
+
pitchLimit && (this.controls.minPolarAngle = MathUtils.degToRad(pitchLimit[0]));
|
|
100
|
+
pitchLimit && (this.controls.maxPolarAngle = MathUtils.degToRad((_2 = pitchLimit[1]) !== null && _2 !== void 0 ? _2 : pitchLimit[0]));
|
|
101
|
+
yawLimit && (this.controls.minAzimuthAngle = MathUtils.degToRad(yawLimit[0]));
|
|
102
|
+
yawLimit && (this.controls.maxAzimuthAngle = MathUtils.degToRad((_3 = yawLimit[1]) !== null && _3 !== void 0 ? _3 : yawLimit[0]));
|
|
103
|
+
}
|
|
144
104
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
value: function setCameraAngle(params) {
|
|
152
|
-
var pitch = params.pitch,
|
|
153
|
-
yaw = params.yaw,
|
|
154
|
-
distance = params.distance;
|
|
155
|
-
distance && this.setCameraDistance(distance);
|
|
156
|
-
yaw !== undefined && this.cameraUtils.setYaw(yaw);
|
|
157
|
-
pitch !== undefined && this.cameraUtils.setPitch(pitch);
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
key: "setCameraDistance",
|
|
161
|
-
value: function setCameraDistance(distance) {
|
|
162
|
-
var target = this.controls.target;
|
|
163
|
-
var position = this.camera.position;
|
|
164
|
-
var direction = new Vector3().subVectors(position, target).normalize();
|
|
165
|
-
var newPosition = target.clone().add(direction.multiplyScalar(distance));
|
|
166
|
-
this.camera.position.copy(newPosition);
|
|
167
|
-
}
|
|
168
|
-
}, {
|
|
169
|
-
key: "setCameraTarget",
|
|
170
|
-
value: function setCameraTarget() {
|
|
171
|
-
var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.target.toArray();
|
|
172
|
-
this.controls.target.copy(new Vector3().fromArray(target));
|
|
173
|
-
}
|
|
105
|
+
/**
|
|
106
|
+
* set camera position、target、distance
|
|
107
|
+
*/
|
|
108
|
+
setCameraPosition(position) {
|
|
109
|
+
this.camera.position.copy(new Vector3().fromArray(position));
|
|
110
|
+
}
|
|
174
111
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
to: 'setCameraMode'
|
|
200
|
-
}, {
|
|
201
|
-
name: 'handleTarget',
|
|
202
|
-
from: 'setCameraMode',
|
|
203
|
-
to: 'setCameraTarget'
|
|
204
|
-
}, {
|
|
205
|
-
name: 'handleMiddel',
|
|
206
|
-
from: 'setCameraTarget',
|
|
207
|
-
to: '*'
|
|
208
|
-
}, {
|
|
209
|
-
name: 'handlePosition',
|
|
210
|
-
from: '*',
|
|
211
|
-
to: 'setCameraLimitOption'
|
|
212
|
-
}, {
|
|
213
|
-
name: 'handleAngle',
|
|
214
|
-
from: '*',
|
|
215
|
-
to: 'setCameraLimitOption'
|
|
216
|
-
}, {
|
|
217
|
-
name: 'handleLimit',
|
|
218
|
-
from: '*'
|
|
219
|
-
}],
|
|
220
|
-
methods: {
|
|
221
|
-
onHandleBaseOption: function onHandleBaseOption() {
|
|
222
|
-
return _this2.setCameraOption({
|
|
223
|
-
fov: fov
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
onHandleMode: function onHandleMode() {
|
|
227
|
-
return _this2.setCameraMode();
|
|
228
|
-
},
|
|
229
|
-
onHandleTarget: function onHandleTarget() {
|
|
230
|
-
return _this2.setCameraTarget(target);
|
|
231
|
-
},
|
|
232
|
-
onHandlePosition: function onHandlePosition() {
|
|
233
|
-
return _this2.setCameraPosition(position);
|
|
234
|
-
},
|
|
235
|
-
onHandleAngle: function onHandleAngle() {
|
|
236
|
-
_this2.setCameraAngle({
|
|
237
|
-
pitch: pitch,
|
|
238
|
-
yaw: yaw,
|
|
239
|
-
distance: distance
|
|
240
|
-
});
|
|
241
|
-
},
|
|
242
|
-
onHandleLimit: function onHandleLimit() {
|
|
243
|
-
return _this2.setCameraLimitOption({
|
|
244
|
-
pitchLimit: pitchLimit,
|
|
245
|
-
yawLimit: yawLimit,
|
|
246
|
-
distanceLimit: distanceLimit
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
fsm.handleBaseOption();
|
|
252
|
-
fsm.handleMode();
|
|
253
|
-
fsm.handleTarget();
|
|
254
|
-
position ? fsm.handlePosition() : fsm.handleAngle();
|
|
255
|
-
fsm.handleLimit();
|
|
256
|
-
this.isTrigger = isTrigger;
|
|
257
|
-
return _context2.abrupt("return", this.get());
|
|
258
|
-
case 10:
|
|
259
|
-
case "end":
|
|
260
|
-
return _context2.stop();
|
|
261
|
-
}
|
|
262
|
-
}, _callee2, this);
|
|
263
|
-
}));
|
|
264
|
-
function set(_x2) {
|
|
265
|
-
return _set.apply(this, arguments);
|
|
266
|
-
}
|
|
267
|
-
return set;
|
|
268
|
-
}()
|
|
269
|
-
/**
|
|
270
|
-
* get Camera info
|
|
271
|
-
* @returns
|
|
272
|
-
*/
|
|
273
|
-
)
|
|
274
|
-
}, {
|
|
275
|
-
key: "get",
|
|
276
|
-
value: function get() {
|
|
277
|
-
return {
|
|
278
|
-
fov: this.camera.fov,
|
|
279
|
-
mode: 'orbitCamera',
|
|
280
|
-
position: [this.camera.position.x, this.camera.position.y, this.camera.position.z],
|
|
281
|
-
target: [this.controls.target.x, this.controls.target.y, this.controls.target.z],
|
|
282
|
-
distance: this.controls.target.distanceTo(this.camera.position),
|
|
283
|
-
pitch: this.cameraUtils.pitch,
|
|
284
|
-
yaw: this.cameraUtils.yaw
|
|
285
|
-
};
|
|
286
|
-
}
|
|
112
|
+
/**
|
|
113
|
+
* set camera angle, example:pitch、yaw、distance
|
|
114
|
+
* @param params
|
|
115
|
+
*/
|
|
116
|
+
setCameraAngle(params) {
|
|
117
|
+
const {
|
|
118
|
+
pitch,
|
|
119
|
+
yaw,
|
|
120
|
+
distance
|
|
121
|
+
} = params;
|
|
122
|
+
distance && this.setCameraDistance(distance);
|
|
123
|
+
yaw !== undefined && this.cameraUtils.setYaw(yaw);
|
|
124
|
+
pitch !== undefined && this.cameraUtils.setPitch(pitch);
|
|
125
|
+
}
|
|
126
|
+
setCameraDistance(distance) {
|
|
127
|
+
const target = this.controls.target;
|
|
128
|
+
const position = this.camera.position;
|
|
129
|
+
const direction = new Vector3().subVectors(position, target).normalize();
|
|
130
|
+
const newPosition = target.clone().add(direction.multiplyScalar(distance));
|
|
131
|
+
this.camera.position.copy(newPosition);
|
|
132
|
+
}
|
|
133
|
+
setCameraTarget(target = this.target.toArray()) {
|
|
134
|
+
this.controls.target.copy(new Vector3().fromArray(target));
|
|
135
|
+
}
|
|
287
136
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
137
|
+
/**
|
|
138
|
+
* set camera
|
|
139
|
+
* @param params
|
|
140
|
+
*/
|
|
141
|
+
set(params) {
|
|
142
|
+
var _this2 = this;
|
|
143
|
+
return _asyncToGenerator(function* () {
|
|
144
|
+
const {
|
|
145
|
+
fov = 45,
|
|
146
|
+
isTrigger = true,
|
|
147
|
+
target = [0, 0, 0],
|
|
148
|
+
position,
|
|
149
|
+
distance,
|
|
150
|
+
pitch,
|
|
151
|
+
yaw,
|
|
152
|
+
pitchLimit,
|
|
153
|
+
yawLimit,
|
|
154
|
+
distanceLimit
|
|
155
|
+
} = params;
|
|
156
|
+
_this2.target = new Vector3().fromArray(target);
|
|
157
|
+
const fsm = new StateMachine({
|
|
158
|
+
init: 'start',
|
|
159
|
+
transitions: [{
|
|
160
|
+
name: 'handleBaseOption',
|
|
161
|
+
from: 'start',
|
|
162
|
+
to: 'setBaseOption'
|
|
163
|
+
}, {
|
|
164
|
+
name: 'handleMode',
|
|
165
|
+
from: 'setBaseOption',
|
|
166
|
+
to: 'setCameraMode'
|
|
167
|
+
}, {
|
|
168
|
+
name: 'handleTarget',
|
|
169
|
+
from: 'setCameraMode',
|
|
170
|
+
to: 'setCameraTarget'
|
|
171
|
+
}, {
|
|
172
|
+
name: 'handleMiddel',
|
|
173
|
+
from: 'setCameraTarget',
|
|
174
|
+
to: '*'
|
|
175
|
+
}, {
|
|
176
|
+
name: 'handlePosition',
|
|
177
|
+
from: '*',
|
|
178
|
+
to: 'setCameraLimitOption'
|
|
179
|
+
}, {
|
|
180
|
+
name: 'handleAngle',
|
|
181
|
+
from: '*',
|
|
182
|
+
to: 'setCameraLimitOption'
|
|
183
|
+
}, {
|
|
184
|
+
name: 'handleLimit',
|
|
185
|
+
from: '*'
|
|
186
|
+
}],
|
|
187
|
+
methods: {
|
|
188
|
+
onHandleBaseOption: () => _this2.setCameraOption({
|
|
189
|
+
fov
|
|
190
|
+
}),
|
|
191
|
+
onHandleMode: () => _this2.setCameraMode(),
|
|
192
|
+
onHandleTarget: () => _this2.setCameraTarget(target),
|
|
193
|
+
onHandlePosition: () => _this2.setCameraPosition(position),
|
|
194
|
+
onHandleAngle: () => {
|
|
195
|
+
_this2.setCameraAngle({
|
|
196
|
+
pitch,
|
|
197
|
+
yaw,
|
|
198
|
+
distance
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
onHandleLimit: () => _this2.setCameraLimitOption({
|
|
202
|
+
pitchLimit,
|
|
203
|
+
yawLimit,
|
|
204
|
+
distanceLimit
|
|
205
|
+
})
|
|
206
|
+
}
|
|
311
207
|
});
|
|
312
|
-
|
|
208
|
+
fsm.handleBaseOption();
|
|
209
|
+
fsm.handleMode();
|
|
210
|
+
fsm.handleTarget();
|
|
211
|
+
position ? fsm.handlePosition() : fsm.handleAngle();
|
|
212
|
+
fsm.handleLimit();
|
|
213
|
+
_this2.isTrigger = isTrigger;
|
|
214
|
+
return _this2.get();
|
|
215
|
+
})();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* get Camera info
|
|
220
|
+
* @returns
|
|
221
|
+
*/
|
|
222
|
+
get() {
|
|
223
|
+
return {
|
|
224
|
+
fov: this.camera.fov,
|
|
225
|
+
mode: 'orbitCamera',
|
|
226
|
+
position: [this.camera.position.x, this.camera.position.y, this.camera.position.z],
|
|
227
|
+
target: [this.controls.target.x, this.controls.target.y, this.controls.target.z],
|
|
228
|
+
distance: this.controls.target.distanceTo(this.camera.position),
|
|
229
|
+
pitch: this.cameraUtils.pitch,
|
|
230
|
+
yaw: this.cameraUtils.yaw
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* follow object
|
|
236
|
+
* @param params
|
|
237
|
+
*/
|
|
238
|
+
follow(params) {
|
|
239
|
+
const {
|
|
240
|
+
target,
|
|
241
|
+
pitch = 30,
|
|
242
|
+
yaw = 0,
|
|
243
|
+
distance = 0,
|
|
244
|
+
relativeRotation = false
|
|
245
|
+
} = params;
|
|
246
|
+
const targetObject = hybridList.get(target);
|
|
247
|
+
this.cameraUtils.cancelAllFollow();
|
|
248
|
+
return this.cameraUtils.follow(targetObject, this.camera, {
|
|
249
|
+
relativeRotation,
|
|
250
|
+
pitch,
|
|
251
|
+
yaw,
|
|
252
|
+
distance
|
|
253
|
+
});
|
|
254
|
+
}
|
|
313
255
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
}]);
|
|
323
|
-
return Camera;
|
|
324
|
-
}();
|
|
256
|
+
/**
|
|
257
|
+
* cancel follow
|
|
258
|
+
*/
|
|
259
|
+
cancelFollow() {
|
|
260
|
+
this.cameraUtils.cancelAllFollow();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
325
263
|
export default Camera;
|
|
326
264
|
//# sourceMappingURL=index.js.map
|