@realsee/dnalogel 2.0.0-alpha.52 → 2.0.0-alpha.53
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/CruisePlugin/index.js +188 -5
- package/dist/GuideLinePlugin/index.js +188 -5
- package/dist/index.es.js +188 -2
- package/dist/index.js +188 -3
- package/dist/index.umd.js +192 -6
- package/docs/classes/CruisePluginController.html +14 -14
- package/docs/classes/Magnifier.html +4 -4
- package/docs/classes/ModelRoomLabelController.html +4 -4
- package/docs/enums/CameraMovementEffect.html +2 -2
- package/docs/enums/DIRECTION.html +1 -1
- package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/Rotation.html +2 -2
- package/docs/index.html +1 -1
- package/docs/interfaces/CSS3DRenderPluginExportType.html +2 -2
- package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
- package/docs/interfaces/FloorplanBounding.html +4 -4
- package/docs/interfaces/FloorplanData.html +2 -2
- package/docs/interfaces/FloorplanEntrance.html +7 -7
- package/docs/interfaces/FloorplanExtraObject.html +3 -3
- package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
- package/docs/interfaces/FloorplanFloorData.html +2 -2
- package/docs/interfaces/FloorplanImagePosition.html +2 -2
- package/docs/interfaces/FloorplanObserver.html +2 -2
- package/docs/interfaces/FloorplanOutlineItem.html +2 -2
- package/docs/interfaces/FloorplanPosition.html +2 -2
- package/docs/interfaces/FloorplanRoomItem.html +6 -6
- package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
- package/docs/interfaces/FloorplanServerBounding.html +4 -4
- package/docs/interfaces/FloorplanServerComputedData.html +1 -1
- package/docs/interfaces/FloorplanServerData.html +2 -2
- package/docs/interfaces/FloorplanServerDoorItem.html +1 -1
- package/docs/interfaces/FloorplanServerDoorPosition.html +1 -1
- package/docs/interfaces/FloorplanServerEntrance.html +7 -7
- package/docs/interfaces/FloorplanServerFloorData.html +2 -2
- package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
- package/docs/interfaces/FloorplanServerObserver.html +2 -2
- package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
- package/docs/interfaces/FloorplanServerPosition.html +2 -2
- package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
- package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
- package/docs/interfaces/ItemLabelPluginData.html +1 -1
- package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/LineJson.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/ModelViewPluginExportType.html +1 -1
- package/docs/interfaces/OpenParameter.html +2 -2
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
- package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
- package/docs/interfaces/PanoMeasureParameterType.html +1 -1
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginState.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
- package/docs/interfaces/Point.html +1 -1
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/Room.html +1 -1
- package/docs/interfaces/RoomInfo.html +1 -1
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/RoomRules.html +1 -1
- package/docs/interfaces/Rooms.html +1 -1
- package/docs/modules.html +18 -18
- package/package.json +2 -1
|
@@ -4,9 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var five = require('@realsee/five');
|
|
6
6
|
var THREE = require('three');
|
|
7
|
-
var getNormals = require('polyline-normals');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
7
|
|
|
11
8
|
function _interopNamespace(e) {
|
|
12
9
|
if (e && e.__esModule) return e;
|
|
@@ -27,7 +24,6 @@ function _interopNamespace(e) {
|
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
30
|
-
var getNormals__default = /*#__PURE__*/_interopDefaultLegacy(getNormals);
|
|
31
27
|
|
|
32
28
|
/**
|
|
33
29
|
* plugin 的基本控制器
|
|
@@ -62,6 +58,193 @@ class Controller$2 {
|
|
|
62
58
|
class Controller$1 extends Controller$2 {
|
|
63
59
|
}
|
|
64
60
|
|
|
61
|
+
var polylineMiterUtil = {};
|
|
62
|
+
|
|
63
|
+
var add_1 = add$1;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Adds two vec2's
|
|
67
|
+
*
|
|
68
|
+
* @param {vec2} out the receiving vector
|
|
69
|
+
* @param {vec2} a the first operand
|
|
70
|
+
* @param {vec2} b the second operand
|
|
71
|
+
* @returns {vec2} out
|
|
72
|
+
*/
|
|
73
|
+
function add$1(out, a, b) {
|
|
74
|
+
out[0] = a[0] + b[0];
|
|
75
|
+
out[1] = a[1] + b[1];
|
|
76
|
+
return out
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var set_1 = set$1;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Set the components of a vec2 to the given values
|
|
83
|
+
*
|
|
84
|
+
* @param {vec2} out the receiving vector
|
|
85
|
+
* @param {Number} x X component
|
|
86
|
+
* @param {Number} y Y component
|
|
87
|
+
* @returns {vec2} out
|
|
88
|
+
*/
|
|
89
|
+
function set$1(out, x, y) {
|
|
90
|
+
out[0] = x;
|
|
91
|
+
out[1] = y;
|
|
92
|
+
return out
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
var normalize_1 = normalize$1;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Normalize a vec2
|
|
99
|
+
*
|
|
100
|
+
* @param {vec2} out the receiving vector
|
|
101
|
+
* @param {vec2} a vector to normalize
|
|
102
|
+
* @returns {vec2} out
|
|
103
|
+
*/
|
|
104
|
+
function normalize$1(out, a) {
|
|
105
|
+
var x = a[0],
|
|
106
|
+
y = a[1];
|
|
107
|
+
var len = x*x + y*y;
|
|
108
|
+
if (len > 0) {
|
|
109
|
+
//TODO: evaluate use of glm_invsqrt here?
|
|
110
|
+
len = 1 / Math.sqrt(len);
|
|
111
|
+
out[0] = a[0] * len;
|
|
112
|
+
out[1] = a[1] * len;
|
|
113
|
+
}
|
|
114
|
+
return out
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var subtract_1 = subtract$1;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Subtracts vector b from vector a
|
|
121
|
+
*
|
|
122
|
+
* @param {vec2} out the receiving vector
|
|
123
|
+
* @param {vec2} a the first operand
|
|
124
|
+
* @param {vec2} b the second operand
|
|
125
|
+
* @returns {vec2} out
|
|
126
|
+
*/
|
|
127
|
+
function subtract$1(out, a, b) {
|
|
128
|
+
out[0] = a[0] - b[0];
|
|
129
|
+
out[1] = a[1] - b[1];
|
|
130
|
+
return out
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
var dot_1 = dot$1;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Calculates the dot product of two vec2's
|
|
137
|
+
*
|
|
138
|
+
* @param {vec2} a the first operand
|
|
139
|
+
* @param {vec2} b the second operand
|
|
140
|
+
* @returns {Number} dot product of a and b
|
|
141
|
+
*/
|
|
142
|
+
function dot$1(a, b) {
|
|
143
|
+
return a[0] * b[0] + a[1] * b[1]
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var add = add_1;
|
|
147
|
+
var set = set_1;
|
|
148
|
+
var normalize = normalize_1;
|
|
149
|
+
var subtract = subtract_1;
|
|
150
|
+
var dot = dot_1;
|
|
151
|
+
|
|
152
|
+
var tmp = [0, 0];
|
|
153
|
+
|
|
154
|
+
polylineMiterUtil.computeMiter = function computeMiter(tangent, miter, lineA, lineB, halfThick) {
|
|
155
|
+
//get tangent line
|
|
156
|
+
add(tangent, lineA, lineB);
|
|
157
|
+
normalize(tangent, tangent);
|
|
158
|
+
|
|
159
|
+
//get miter as a unit vector
|
|
160
|
+
set(miter, -tangent[1], tangent[0]);
|
|
161
|
+
set(tmp, -lineA[1], lineA[0]);
|
|
162
|
+
|
|
163
|
+
//get the necessary length of our miter
|
|
164
|
+
return halfThick / dot(miter, tmp)
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
polylineMiterUtil.normal = function normal(out, dir) {
|
|
168
|
+
//get perpendicular
|
|
169
|
+
set(out, -dir[1], dir[0]);
|
|
170
|
+
return out
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
polylineMiterUtil.direction = function direction(out, a, b) {
|
|
174
|
+
//get unit dir of two lines
|
|
175
|
+
subtract(out, a, b);
|
|
176
|
+
normalize(out, out);
|
|
177
|
+
return out
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
var util = polylineMiterUtil;
|
|
181
|
+
|
|
182
|
+
var lineA = [0, 0];
|
|
183
|
+
var lineB = [0, 0];
|
|
184
|
+
var tangent = [0, 0];
|
|
185
|
+
var miter = [0, 0];
|
|
186
|
+
|
|
187
|
+
var polylineNormals = function(points, closed) {
|
|
188
|
+
var curNormal = null;
|
|
189
|
+
var out = [];
|
|
190
|
+
if (closed) {
|
|
191
|
+
points = points.slice();
|
|
192
|
+
points.push(points[0]);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
var total = points.length;
|
|
196
|
+
for (var i=1; i<total; i++) {
|
|
197
|
+
var last = points[i-1];
|
|
198
|
+
var cur = points[i];
|
|
199
|
+
var next = i<points.length-1 ? points[i+1] : null;
|
|
200
|
+
|
|
201
|
+
util.direction(lineA, cur, last);
|
|
202
|
+
if (!curNormal) {
|
|
203
|
+
curNormal = [0, 0];
|
|
204
|
+
util.normal(curNormal, lineA);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (i === 1) //add initial normals
|
|
208
|
+
addNext(out, curNormal, 1);
|
|
209
|
+
|
|
210
|
+
if (!next) { //no miter, simple segment
|
|
211
|
+
util.normal(curNormal, lineA); //reset normal
|
|
212
|
+
addNext(out, curNormal, 1);
|
|
213
|
+
} else { //miter with last
|
|
214
|
+
//get unit dir of next line
|
|
215
|
+
util.direction(lineB, next, cur);
|
|
216
|
+
|
|
217
|
+
//stores tangent & miter
|
|
218
|
+
var miterLen = util.computeMiter(tangent, miter, lineA, lineB, 1);
|
|
219
|
+
addNext(out, miter, miterLen);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
//if the polyline is a closed loop, clean up the last normal
|
|
224
|
+
if (points.length > 2 && closed) {
|
|
225
|
+
var last2 = points[total-2];
|
|
226
|
+
var cur2 = points[0];
|
|
227
|
+
var next2 = points[1];
|
|
228
|
+
|
|
229
|
+
util.direction(lineA, cur2, last2);
|
|
230
|
+
util.direction(lineB, next2, cur2);
|
|
231
|
+
util.normal(curNormal, lineA);
|
|
232
|
+
|
|
233
|
+
var miterLen2 = util.computeMiter(tangent, miter, lineA, lineB, 1);
|
|
234
|
+
out[0][0] = miter.slice();
|
|
235
|
+
out[total-1][0] = miter.slice();
|
|
236
|
+
out[0][1] = miterLen2;
|
|
237
|
+
out[total-1][1] = miterLen2;
|
|
238
|
+
out.pop();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return out
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
function addNext(out, normal, length) {
|
|
245
|
+
out.push([[normal[0], normal[1]], length]);
|
|
246
|
+
}
|
|
247
|
+
|
|
65
248
|
// 定义常量
|
|
66
249
|
const TRIANGLE_NUMBER_OF_RECTANGLE = 2; // 每个矩形有两个三角形
|
|
67
250
|
const VERTEX_NUMBER_OF_TRIANGLE = 3; // 每个三角形有三个顶点
|
|
@@ -81,7 +264,7 @@ function getLineGeometry(positionList) {
|
|
|
81
264
|
const divisions = Math.ceil(curve.getLength()); // 曲线切片数
|
|
82
265
|
const curvePoints = curve.getPoints(divisions);
|
|
83
266
|
const curvePointsLength = curvePoints.length;
|
|
84
|
-
const normals =
|
|
267
|
+
const normals = polylineNormals(curvePoints.map((p) => [p.x, p.z])); // curvePoints:每个点切线的向量「二维」
|
|
85
268
|
const rectangleNumber = curvePoints.length - 1; // 曲线上 N 个点,构成了 N - 1 个矩形
|
|
86
269
|
const indexNumber = rectangleNumber * TRIANGLE_NUMBER_OF_RECTANGLE * VERTEX_NUMBER_OF_TRIANGLE;
|
|
87
270
|
const verticesNumber = 2 * curvePointsLength; // 顶点数量(包含公用):每个曲线点对应两个顶点,N 个 点有 2N 个顶点
|
|
@@ -4,9 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var five = require('@realsee/five');
|
|
6
6
|
var THREE = require('three');
|
|
7
|
-
var getNormals = require('polyline-normals');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
7
|
|
|
11
8
|
function _interopNamespace(e) {
|
|
12
9
|
if (e && e.__esModule) return e;
|
|
@@ -27,7 +24,6 @@ function _interopNamespace(e) {
|
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
30
|
-
var getNormals__default = /*#__PURE__*/_interopDefaultLegacy(getNormals);
|
|
31
27
|
|
|
32
28
|
/**
|
|
33
29
|
* plugin 的基本控制器
|
|
@@ -62,6 +58,193 @@ class Controller$2 {
|
|
|
62
58
|
class Controller$1 extends Controller$2 {
|
|
63
59
|
}
|
|
64
60
|
|
|
61
|
+
var polylineMiterUtil = {};
|
|
62
|
+
|
|
63
|
+
var add_1 = add$1;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Adds two vec2's
|
|
67
|
+
*
|
|
68
|
+
* @param {vec2} out the receiving vector
|
|
69
|
+
* @param {vec2} a the first operand
|
|
70
|
+
* @param {vec2} b the second operand
|
|
71
|
+
* @returns {vec2} out
|
|
72
|
+
*/
|
|
73
|
+
function add$1(out, a, b) {
|
|
74
|
+
out[0] = a[0] + b[0];
|
|
75
|
+
out[1] = a[1] + b[1];
|
|
76
|
+
return out
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var set_1 = set$1;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Set the components of a vec2 to the given values
|
|
83
|
+
*
|
|
84
|
+
* @param {vec2} out the receiving vector
|
|
85
|
+
* @param {Number} x X component
|
|
86
|
+
* @param {Number} y Y component
|
|
87
|
+
* @returns {vec2} out
|
|
88
|
+
*/
|
|
89
|
+
function set$1(out, x, y) {
|
|
90
|
+
out[0] = x;
|
|
91
|
+
out[1] = y;
|
|
92
|
+
return out
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
var normalize_1 = normalize$1;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Normalize a vec2
|
|
99
|
+
*
|
|
100
|
+
* @param {vec2} out the receiving vector
|
|
101
|
+
* @param {vec2} a vector to normalize
|
|
102
|
+
* @returns {vec2} out
|
|
103
|
+
*/
|
|
104
|
+
function normalize$1(out, a) {
|
|
105
|
+
var x = a[0],
|
|
106
|
+
y = a[1];
|
|
107
|
+
var len = x*x + y*y;
|
|
108
|
+
if (len > 0) {
|
|
109
|
+
//TODO: evaluate use of glm_invsqrt here?
|
|
110
|
+
len = 1 / Math.sqrt(len);
|
|
111
|
+
out[0] = a[0] * len;
|
|
112
|
+
out[1] = a[1] * len;
|
|
113
|
+
}
|
|
114
|
+
return out
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var subtract_1 = subtract$1;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Subtracts vector b from vector a
|
|
121
|
+
*
|
|
122
|
+
* @param {vec2} out the receiving vector
|
|
123
|
+
* @param {vec2} a the first operand
|
|
124
|
+
* @param {vec2} b the second operand
|
|
125
|
+
* @returns {vec2} out
|
|
126
|
+
*/
|
|
127
|
+
function subtract$1(out, a, b) {
|
|
128
|
+
out[0] = a[0] - b[0];
|
|
129
|
+
out[1] = a[1] - b[1];
|
|
130
|
+
return out
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
var dot_1 = dot$1;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Calculates the dot product of two vec2's
|
|
137
|
+
*
|
|
138
|
+
* @param {vec2} a the first operand
|
|
139
|
+
* @param {vec2} b the second operand
|
|
140
|
+
* @returns {Number} dot product of a and b
|
|
141
|
+
*/
|
|
142
|
+
function dot$1(a, b) {
|
|
143
|
+
return a[0] * b[0] + a[1] * b[1]
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var add = add_1;
|
|
147
|
+
var set = set_1;
|
|
148
|
+
var normalize = normalize_1;
|
|
149
|
+
var subtract = subtract_1;
|
|
150
|
+
var dot = dot_1;
|
|
151
|
+
|
|
152
|
+
var tmp = [0, 0];
|
|
153
|
+
|
|
154
|
+
polylineMiterUtil.computeMiter = function computeMiter(tangent, miter, lineA, lineB, halfThick) {
|
|
155
|
+
//get tangent line
|
|
156
|
+
add(tangent, lineA, lineB);
|
|
157
|
+
normalize(tangent, tangent);
|
|
158
|
+
|
|
159
|
+
//get miter as a unit vector
|
|
160
|
+
set(miter, -tangent[1], tangent[0]);
|
|
161
|
+
set(tmp, -lineA[1], lineA[0]);
|
|
162
|
+
|
|
163
|
+
//get the necessary length of our miter
|
|
164
|
+
return halfThick / dot(miter, tmp)
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
polylineMiterUtil.normal = function normal(out, dir) {
|
|
168
|
+
//get perpendicular
|
|
169
|
+
set(out, -dir[1], dir[0]);
|
|
170
|
+
return out
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
polylineMiterUtil.direction = function direction(out, a, b) {
|
|
174
|
+
//get unit dir of two lines
|
|
175
|
+
subtract(out, a, b);
|
|
176
|
+
normalize(out, out);
|
|
177
|
+
return out
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
var util = polylineMiterUtil;
|
|
181
|
+
|
|
182
|
+
var lineA = [0, 0];
|
|
183
|
+
var lineB = [0, 0];
|
|
184
|
+
var tangent = [0, 0];
|
|
185
|
+
var miter = [0, 0];
|
|
186
|
+
|
|
187
|
+
var polylineNormals = function(points, closed) {
|
|
188
|
+
var curNormal = null;
|
|
189
|
+
var out = [];
|
|
190
|
+
if (closed) {
|
|
191
|
+
points = points.slice();
|
|
192
|
+
points.push(points[0]);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
var total = points.length;
|
|
196
|
+
for (var i=1; i<total; i++) {
|
|
197
|
+
var last = points[i-1];
|
|
198
|
+
var cur = points[i];
|
|
199
|
+
var next = i<points.length-1 ? points[i+1] : null;
|
|
200
|
+
|
|
201
|
+
util.direction(lineA, cur, last);
|
|
202
|
+
if (!curNormal) {
|
|
203
|
+
curNormal = [0, 0];
|
|
204
|
+
util.normal(curNormal, lineA);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (i === 1) //add initial normals
|
|
208
|
+
addNext(out, curNormal, 1);
|
|
209
|
+
|
|
210
|
+
if (!next) { //no miter, simple segment
|
|
211
|
+
util.normal(curNormal, lineA); //reset normal
|
|
212
|
+
addNext(out, curNormal, 1);
|
|
213
|
+
} else { //miter with last
|
|
214
|
+
//get unit dir of next line
|
|
215
|
+
util.direction(lineB, next, cur);
|
|
216
|
+
|
|
217
|
+
//stores tangent & miter
|
|
218
|
+
var miterLen = util.computeMiter(tangent, miter, lineA, lineB, 1);
|
|
219
|
+
addNext(out, miter, miterLen);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
//if the polyline is a closed loop, clean up the last normal
|
|
224
|
+
if (points.length > 2 && closed) {
|
|
225
|
+
var last2 = points[total-2];
|
|
226
|
+
var cur2 = points[0];
|
|
227
|
+
var next2 = points[1];
|
|
228
|
+
|
|
229
|
+
util.direction(lineA, cur2, last2);
|
|
230
|
+
util.direction(lineB, next2, cur2);
|
|
231
|
+
util.normal(curNormal, lineA);
|
|
232
|
+
|
|
233
|
+
var miterLen2 = util.computeMiter(tangent, miter, lineA, lineB, 1);
|
|
234
|
+
out[0][0] = miter.slice();
|
|
235
|
+
out[total-1][0] = miter.slice();
|
|
236
|
+
out[0][1] = miterLen2;
|
|
237
|
+
out[total-1][1] = miterLen2;
|
|
238
|
+
out.pop();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return out
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
function addNext(out, normal, length) {
|
|
245
|
+
out.push([[normal[0], normal[1]], length]);
|
|
246
|
+
}
|
|
247
|
+
|
|
65
248
|
// 定义常量
|
|
66
249
|
const TRIANGLE_NUMBER_OF_RECTANGLE = 2; // 每个矩形有两个三角形
|
|
67
250
|
const VERTEX_NUMBER_OF_TRIANGLE = 3; // 每个三角形有三个顶点
|
|
@@ -81,7 +264,7 @@ function getLineGeometry(positionList) {
|
|
|
81
264
|
const divisions = Math.ceil(curve.getLength()); // 曲线切片数
|
|
82
265
|
const curvePoints = curve.getPoints(divisions);
|
|
83
266
|
const curvePointsLength = curvePoints.length;
|
|
84
|
-
const normals =
|
|
267
|
+
const normals = polylineNormals(curvePoints.map((p) => [p.x, p.z])); // curvePoints:每个点切线的向量「二维」
|
|
85
268
|
const rectangleNumber = curvePoints.length - 1; // 曲线上 N 个点,构成了 N - 1 个矩形
|
|
86
269
|
const indexNumber = rectangleNumber * TRIANGLE_NUMBER_OF_RECTANGLE * VERTEX_NUMBER_OF_TRIANGLE;
|
|
87
270
|
const verticesNumber = 2 * curvePointsLength; // 顶点数量(包含公用):每个曲线点对应两个顶点,N 个 点有 2N 个顶点
|
package/dist/index.es.js
CHANGED
|
@@ -13,7 +13,6 @@ import * as TWEEN from '@tweenjs/tween.js';
|
|
|
13
13
|
import TWEEN__default from '@tweenjs/tween.js';
|
|
14
14
|
import Hammer from 'hammerjs';
|
|
15
15
|
import classNames from 'classnames';
|
|
16
|
-
import getNormals from 'polyline-normals';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Five 模型插件
|
|
@@ -18087,6 +18086,193 @@ const PanoDoorLabelPlugin = (five) => {
|
|
|
18087
18086
|
return new PanoDoorLabelPluginController(five);
|
|
18088
18087
|
};
|
|
18089
18088
|
|
|
18089
|
+
var polylineMiterUtil = {};
|
|
18090
|
+
|
|
18091
|
+
var add_1 = add$1;
|
|
18092
|
+
|
|
18093
|
+
/**
|
|
18094
|
+
* Adds two vec2's
|
|
18095
|
+
*
|
|
18096
|
+
* @param {vec2} out the receiving vector
|
|
18097
|
+
* @param {vec2} a the first operand
|
|
18098
|
+
* @param {vec2} b the second operand
|
|
18099
|
+
* @returns {vec2} out
|
|
18100
|
+
*/
|
|
18101
|
+
function add$1(out, a, b) {
|
|
18102
|
+
out[0] = a[0] + b[0];
|
|
18103
|
+
out[1] = a[1] + b[1];
|
|
18104
|
+
return out
|
|
18105
|
+
}
|
|
18106
|
+
|
|
18107
|
+
var set_1 = set$1;
|
|
18108
|
+
|
|
18109
|
+
/**
|
|
18110
|
+
* Set the components of a vec2 to the given values
|
|
18111
|
+
*
|
|
18112
|
+
* @param {vec2} out the receiving vector
|
|
18113
|
+
* @param {Number} x X component
|
|
18114
|
+
* @param {Number} y Y component
|
|
18115
|
+
* @returns {vec2} out
|
|
18116
|
+
*/
|
|
18117
|
+
function set$1(out, x, y) {
|
|
18118
|
+
out[0] = x;
|
|
18119
|
+
out[1] = y;
|
|
18120
|
+
return out
|
|
18121
|
+
}
|
|
18122
|
+
|
|
18123
|
+
var normalize_1 = normalize$1;
|
|
18124
|
+
|
|
18125
|
+
/**
|
|
18126
|
+
* Normalize a vec2
|
|
18127
|
+
*
|
|
18128
|
+
* @param {vec2} out the receiving vector
|
|
18129
|
+
* @param {vec2} a vector to normalize
|
|
18130
|
+
* @returns {vec2} out
|
|
18131
|
+
*/
|
|
18132
|
+
function normalize$1(out, a) {
|
|
18133
|
+
var x = a[0],
|
|
18134
|
+
y = a[1];
|
|
18135
|
+
var len = x*x + y*y;
|
|
18136
|
+
if (len > 0) {
|
|
18137
|
+
//TODO: evaluate use of glm_invsqrt here?
|
|
18138
|
+
len = 1 / Math.sqrt(len);
|
|
18139
|
+
out[0] = a[0] * len;
|
|
18140
|
+
out[1] = a[1] * len;
|
|
18141
|
+
}
|
|
18142
|
+
return out
|
|
18143
|
+
}
|
|
18144
|
+
|
|
18145
|
+
var subtract_1 = subtract$1;
|
|
18146
|
+
|
|
18147
|
+
/**
|
|
18148
|
+
* Subtracts vector b from vector a
|
|
18149
|
+
*
|
|
18150
|
+
* @param {vec2} out the receiving vector
|
|
18151
|
+
* @param {vec2} a the first operand
|
|
18152
|
+
* @param {vec2} b the second operand
|
|
18153
|
+
* @returns {vec2} out
|
|
18154
|
+
*/
|
|
18155
|
+
function subtract$1(out, a, b) {
|
|
18156
|
+
out[0] = a[0] - b[0];
|
|
18157
|
+
out[1] = a[1] - b[1];
|
|
18158
|
+
return out
|
|
18159
|
+
}
|
|
18160
|
+
|
|
18161
|
+
var dot_1 = dot$1;
|
|
18162
|
+
|
|
18163
|
+
/**
|
|
18164
|
+
* Calculates the dot product of two vec2's
|
|
18165
|
+
*
|
|
18166
|
+
* @param {vec2} a the first operand
|
|
18167
|
+
* @param {vec2} b the second operand
|
|
18168
|
+
* @returns {Number} dot product of a and b
|
|
18169
|
+
*/
|
|
18170
|
+
function dot$1(a, b) {
|
|
18171
|
+
return a[0] * b[0] + a[1] * b[1]
|
|
18172
|
+
}
|
|
18173
|
+
|
|
18174
|
+
var add = add_1;
|
|
18175
|
+
var set = set_1;
|
|
18176
|
+
var normalize = normalize_1;
|
|
18177
|
+
var subtract = subtract_1;
|
|
18178
|
+
var dot = dot_1;
|
|
18179
|
+
|
|
18180
|
+
var tmp = [0, 0];
|
|
18181
|
+
|
|
18182
|
+
polylineMiterUtil.computeMiter = function computeMiter(tangent, miter, lineA, lineB, halfThick) {
|
|
18183
|
+
//get tangent line
|
|
18184
|
+
add(tangent, lineA, lineB);
|
|
18185
|
+
normalize(tangent, tangent);
|
|
18186
|
+
|
|
18187
|
+
//get miter as a unit vector
|
|
18188
|
+
set(miter, -tangent[1], tangent[0]);
|
|
18189
|
+
set(tmp, -lineA[1], lineA[0]);
|
|
18190
|
+
|
|
18191
|
+
//get the necessary length of our miter
|
|
18192
|
+
return halfThick / dot(miter, tmp)
|
|
18193
|
+
};
|
|
18194
|
+
|
|
18195
|
+
polylineMiterUtil.normal = function normal(out, dir) {
|
|
18196
|
+
//get perpendicular
|
|
18197
|
+
set(out, -dir[1], dir[0]);
|
|
18198
|
+
return out
|
|
18199
|
+
};
|
|
18200
|
+
|
|
18201
|
+
polylineMiterUtil.direction = function direction(out, a, b) {
|
|
18202
|
+
//get unit dir of two lines
|
|
18203
|
+
subtract(out, a, b);
|
|
18204
|
+
normalize(out, out);
|
|
18205
|
+
return out
|
|
18206
|
+
};
|
|
18207
|
+
|
|
18208
|
+
var util = polylineMiterUtil;
|
|
18209
|
+
|
|
18210
|
+
var lineA = [0, 0];
|
|
18211
|
+
var lineB = [0, 0];
|
|
18212
|
+
var tangent = [0, 0];
|
|
18213
|
+
var miter = [0, 0];
|
|
18214
|
+
|
|
18215
|
+
var polylineNormals = function(points, closed) {
|
|
18216
|
+
var curNormal = null;
|
|
18217
|
+
var out = [];
|
|
18218
|
+
if (closed) {
|
|
18219
|
+
points = points.slice();
|
|
18220
|
+
points.push(points[0]);
|
|
18221
|
+
}
|
|
18222
|
+
|
|
18223
|
+
var total = points.length;
|
|
18224
|
+
for (var i=1; i<total; i++) {
|
|
18225
|
+
var last = points[i-1];
|
|
18226
|
+
var cur = points[i];
|
|
18227
|
+
var next = i<points.length-1 ? points[i+1] : null;
|
|
18228
|
+
|
|
18229
|
+
util.direction(lineA, cur, last);
|
|
18230
|
+
if (!curNormal) {
|
|
18231
|
+
curNormal = [0, 0];
|
|
18232
|
+
util.normal(curNormal, lineA);
|
|
18233
|
+
}
|
|
18234
|
+
|
|
18235
|
+
if (i === 1) //add initial normals
|
|
18236
|
+
addNext(out, curNormal, 1);
|
|
18237
|
+
|
|
18238
|
+
if (!next) { //no miter, simple segment
|
|
18239
|
+
util.normal(curNormal, lineA); //reset normal
|
|
18240
|
+
addNext(out, curNormal, 1);
|
|
18241
|
+
} else { //miter with last
|
|
18242
|
+
//get unit dir of next line
|
|
18243
|
+
util.direction(lineB, next, cur);
|
|
18244
|
+
|
|
18245
|
+
//stores tangent & miter
|
|
18246
|
+
var miterLen = util.computeMiter(tangent, miter, lineA, lineB, 1);
|
|
18247
|
+
addNext(out, miter, miterLen);
|
|
18248
|
+
}
|
|
18249
|
+
}
|
|
18250
|
+
|
|
18251
|
+
//if the polyline is a closed loop, clean up the last normal
|
|
18252
|
+
if (points.length > 2 && closed) {
|
|
18253
|
+
var last2 = points[total-2];
|
|
18254
|
+
var cur2 = points[0];
|
|
18255
|
+
var next2 = points[1];
|
|
18256
|
+
|
|
18257
|
+
util.direction(lineA, cur2, last2);
|
|
18258
|
+
util.direction(lineB, next2, cur2);
|
|
18259
|
+
util.normal(curNormal, lineA);
|
|
18260
|
+
|
|
18261
|
+
var miterLen2 = util.computeMiter(tangent, miter, lineA, lineB, 1);
|
|
18262
|
+
out[0][0] = miter.slice();
|
|
18263
|
+
out[total-1][0] = miter.slice();
|
|
18264
|
+
out[0][1] = miterLen2;
|
|
18265
|
+
out[total-1][1] = miterLen2;
|
|
18266
|
+
out.pop();
|
|
18267
|
+
}
|
|
18268
|
+
|
|
18269
|
+
return out
|
|
18270
|
+
};
|
|
18271
|
+
|
|
18272
|
+
function addNext(out, normal, length) {
|
|
18273
|
+
out.push([[normal[0], normal[1]], length]);
|
|
18274
|
+
}
|
|
18275
|
+
|
|
18090
18276
|
// 定义常量
|
|
18091
18277
|
const TRIANGLE_NUMBER_OF_RECTANGLE = 2; // 每个矩形有两个三角形
|
|
18092
18278
|
const VERTEX_NUMBER_OF_TRIANGLE = 3; // 每个三角形有三个顶点
|
|
@@ -18106,7 +18292,7 @@ function getLineGeometry(positionList) {
|
|
|
18106
18292
|
const divisions = Math.ceil(curve.getLength()); // 曲线切片数
|
|
18107
18293
|
const curvePoints = curve.getPoints(divisions);
|
|
18108
18294
|
const curvePointsLength = curvePoints.length;
|
|
18109
|
-
const normals =
|
|
18295
|
+
const normals = polylineNormals(curvePoints.map((p) => [p.x, p.z])); // curvePoints:每个点切线的向量「二维」
|
|
18110
18296
|
const rectangleNumber = curvePoints.length - 1; // 曲线上 N 个点,构成了 N - 1 个矩形
|
|
18111
18297
|
const indexNumber = rectangleNumber * TRIANGLE_NUMBER_OF_RECTANGLE * VERTEX_NUMBER_OF_TRIANGLE;
|
|
18112
18298
|
const verticesNumber = 2 * curvePointsLength; // 顶点数量(包含公用):每个曲线点对应两个顶点,N 个 点有 2N 个顶点
|