jsxgraph 1.4.4 → 1.4.6
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/README.md +24 -0
- package/build/Readme.md +17 -0
- package/build/bin/jsxcompressor.js +1 -0
- package/build/bin/jsxgraphcore-min.js +7 -0
- package/build/bin/jsxgraphcore.js +83017 -0
- package/build/bin/jsxgraphcore.min.js +67 -0
- package/build/compressor.build.json +14 -0
- package/build/compressor.deps.js +8 -0
- package/build/core-amd.build.json +14 -0
- package/build/core-amd.deps.js +81 -0
- package/build/core.build.json +14 -0
- package/build/core.deps.js +102 -0
- package/build/plot.build.json +15 -0
- package/distrib/README.md +24 -0
- package/distrib/geogebra.min.js +1 -1
- package/distrib/geonext.min.js +1 -1
- package/distrib/index.d.ts +28 -7
- package/distrib/intergeo.min.js +1 -1
- package/distrib/jsxgraph.css +6 -0
- package/distrib/jsxgraphcore.js +3 -3
- package/distrib/jsxgraphsrc.js +3558 -1857
- package/distrib/sketch.min.js +1 -1
- package/package.json +1 -1
- package/src/3d/box3d.js +43 -38
- package/src/3d/curve3d.js +157 -53
- package/src/3d/element3d.js +84 -0
- package/src/3d/linspace3d.js +427 -146
- package/src/3d/point3d.js +360 -123
- package/src/3d/surface3d.js +140 -42
- package/src/3d/view3d.js +319 -164
- package/src/base/board.js +163 -78
- package/src/base/constants.js +8 -1
- package/src/base/curve.js +51 -9
- package/src/base/polygon.js +111 -69
- package/src/base/text.js +122 -19
- package/src/base/ticks.js +12 -3
- package/src/element/button.js +7 -3
- package/src/element/checkbox.js +8 -4
- package/src/element/composition.js +7 -1
- package/src/element/conic.js +2 -2
- package/src/element/input.js +9 -5
- package/src/jsxgraph.js +4 -1
- package/src/loadjsxgraph.js +13 -8
- package/src/math/clip.js +34 -134
- package/src/math/geometry.js +204 -3
- package/src/math/math.js +1 -2
- package/src/math/nlp.js +865 -774
- package/src/options.js +185 -12
- package/src/options3d.js +24 -7
- package/src/parser/jessiecode.js +9 -3
- package/src/renderer/abstract.js +26 -15
- package/src/renderer/canvas.js +2 -2
- package/src/renderer/svg.js +15 -2
- package/src/utils/env.js +36 -53
- package/src/utils/type.js +75 -2
- package/src/3d/threed.js +0 -38
package/distrib/sketch.min.js
CHANGED
package/package.json
CHANGED
package/src/3d/box3d.js
CHANGED
|
@@ -30,13 +30,12 @@
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Create axes and rear and front walls of the
|
|
33
|
-
* view3d bounding box
|
|
33
|
+
* view3d bounding box bbox3D.
|
|
34
34
|
*/
|
|
35
|
-
define(['jxg', 'utils/type', 'math/math', 'math/geometry',
|
|
36
|
-
], function (JXG, Type, Mat, Geometry, ThreeD) {
|
|
35
|
+
define(['jxg', 'utils/type', 'math/math', 'math/geometry'], function (JXG, Type, Mat, Geometry) {
|
|
37
36
|
"use strict";
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
JXG.createAxes3D = function (board, parents, attributes) {
|
|
40
39
|
var view = parents[0],
|
|
41
40
|
i, j, k, i1, i2,
|
|
42
41
|
attr,
|
|
@@ -53,10 +52,10 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
53
52
|
ticks_attr,
|
|
54
53
|
axes = {};
|
|
55
54
|
|
|
56
|
-
if (Type.exists(view.
|
|
55
|
+
if (Type.exists(view.bbox3D)) {
|
|
57
56
|
for (i = 0; i < directions.length; i++) {
|
|
58
|
-
rear[i] = view.
|
|
59
|
-
front[i] = view.
|
|
57
|
+
rear[i] = view.bbox3D[i][0];
|
|
58
|
+
front[i] = view.bbox3D[i][1];
|
|
60
59
|
}
|
|
61
60
|
} else {
|
|
62
61
|
for (i = 0; i < directions.length; i++) {
|
|
@@ -108,7 +107,7 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
// Origin (2D point)
|
|
111
|
-
axes.O =
|
|
110
|
+
axes.O = view.create('intersection', [
|
|
112
111
|
axes[directions[0] + suffixAxis],
|
|
113
112
|
axes[directions[1] + suffixAxis]
|
|
114
113
|
], {
|
|
@@ -136,9 +135,8 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
136
135
|
na = dir + 'Plane' + sides[j];
|
|
137
136
|
|
|
138
137
|
attr = Type.copyAttributes(attributes, board.options, 'axes3d', na);
|
|
139
|
-
axes[na] =
|
|
140
|
-
|
|
141
|
-
axes[na].D3.elType = 'axisplane3d';
|
|
138
|
+
axes[na] = view.create('plane3d', [from, vec1, vec2, range1, range2], attr);
|
|
139
|
+
axes[na].elType = 'axisplane3d';
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
|
|
@@ -163,16 +161,16 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
163
161
|
attr = Type.copyAttributes(attributes, board.options, 'axes3d', na);
|
|
164
162
|
axes[na] = view.create('axis3d', [from, to], attr);
|
|
165
163
|
axes[na_parent].addChild(axes[na]);
|
|
166
|
-
axes[na_parent].inherits.push(axes[na]);
|
|
164
|
+
axes[na_parent].element2D.inherits.push(axes[na]); // TODO: Access of element2D is not nice
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
167
|
}
|
|
170
168
|
|
|
171
169
|
return axes;
|
|
172
170
|
};
|
|
173
|
-
JXG.registerElement('axes3d',
|
|
171
|
+
JXG.registerElement('axes3d', JXG.createAxes3D);
|
|
174
172
|
|
|
175
|
-
|
|
173
|
+
JXG.createAxis3D = function (board, parents, attributes) {
|
|
176
174
|
var view = parents[0],
|
|
177
175
|
attr,
|
|
178
176
|
start = parents[1],
|
|
@@ -181,7 +179,7 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
181
179
|
|
|
182
180
|
// Use 2D points to create axis
|
|
183
181
|
attr = Type.copyAttributes(attributes.point1, board.options, 'axis3d', 'point1');
|
|
184
|
-
el_start =
|
|
182
|
+
el_start = view.create('point', [
|
|
185
183
|
(function (xx, yy, zz) {
|
|
186
184
|
return function () { return view.project3DTo2D(xx, yy, zz)[1]; };
|
|
187
185
|
})(start[0], start[1], start[2]),
|
|
@@ -191,7 +189,7 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
191
189
|
], attr);
|
|
192
190
|
|
|
193
191
|
attr = Type.copyAttributes(attributes.point2, board.options, 'axis3d', 'point2');
|
|
194
|
-
el_end =
|
|
192
|
+
el_end = view.create('point', [
|
|
195
193
|
(function (xx, yy, zz) {
|
|
196
194
|
return function () { return view.project3DTo2D(xx, yy, zz)[1]; };
|
|
197
195
|
})(end[0], end[1], end[2]),
|
|
@@ -201,22 +199,22 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
201
199
|
], attr);
|
|
202
200
|
|
|
203
201
|
attr = Type.copyAttributes(attributes, board.options, 'axis3d');
|
|
204
|
-
el =
|
|
202
|
+
el = view.create('arrow', [el_start, el_end], attr);
|
|
205
203
|
|
|
206
204
|
return el;
|
|
207
205
|
};
|
|
208
|
-
JXG.registerElement('axis3d',
|
|
206
|
+
JXG.registerElement('axis3d', JXG.createAxis3D);
|
|
209
207
|
|
|
210
|
-
|
|
208
|
+
JXG.createMesh3D = function (board, parents, attr) {
|
|
211
209
|
var view = parents[0],
|
|
212
210
|
point = parents[1],
|
|
213
|
-
|
|
211
|
+
dir1 = parents[2],
|
|
214
212
|
range1 = parents[3],
|
|
215
|
-
|
|
213
|
+
dir2 = parents[4],
|
|
216
214
|
range2 = parents[5],
|
|
217
215
|
el;
|
|
218
216
|
|
|
219
|
-
el =
|
|
217
|
+
el = view.create('curve', [[], []], attr);
|
|
220
218
|
el.updateDataArray = function () {
|
|
221
219
|
var s1 = range1[0],
|
|
222
220
|
e1 = range1[1],
|
|
@@ -231,10 +229,16 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
231
229
|
this.dataX = [];
|
|
232
230
|
this.dataY = [];
|
|
233
231
|
|
|
232
|
+
if (Type.isFunction(point)) {
|
|
233
|
+
q = point().slice(1);
|
|
234
|
+
} else {
|
|
235
|
+
for (i = 0; i < 3; i++) {
|
|
236
|
+
q[i] = Type.evaluate(point[i]);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
234
239
|
for (i = 0; i < 3; i++) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
v2[i] = Type.evaluate(vec2[i]);
|
|
240
|
+
v1[i] = Type.evaluate(dir1[i]);
|
|
241
|
+
v2[i] = Type.evaluate(dir2[i]);
|
|
238
242
|
}
|
|
239
243
|
l1 = JXG.Math.norm(v1, 3);
|
|
240
244
|
l2 = JXG.Math.norm(v2, 3);
|
|
@@ -242,20 +246,21 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
242
246
|
v1[i] /= l1;
|
|
243
247
|
v2[i] /= l2;
|
|
244
248
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
249
|
+
|
|
250
|
+
// sol = Mat.Geometry.getPlaneBounds(v1, v2, q, s1, e1);
|
|
251
|
+
// if (sol !== null) {
|
|
252
|
+
// s1 = sol[0];
|
|
253
|
+
// e1 = sol[1];
|
|
254
|
+
// s2 = sol[2];
|
|
255
|
+
// e2 = sol[3];
|
|
256
|
+
// }
|
|
254
257
|
|
|
255
258
|
res = view.getMesh(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
+
[
|
|
260
|
+
function(u, v) { return q[0] + u * v1[0] + v * v2[0]; },
|
|
261
|
+
function(u, v) { return q[1] + u * v1[1] + v * v2[1]; },
|
|
262
|
+
function(u, v) { return q[2] + u * v1[2] + v * v2[2]; }
|
|
263
|
+
],
|
|
259
264
|
[Math.ceil(s1), Math.floor(e1), (Math.ceil(e1) - Math.floor(s1)) / step],
|
|
260
265
|
[Math.ceil(s2), Math.floor(e2), (Math.ceil(e2) - Math.floor(s2)) / step]);
|
|
261
266
|
this.dataX = res[0];
|
|
@@ -263,6 +268,6 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
|
|
|
263
268
|
};
|
|
264
269
|
return el;
|
|
265
270
|
};
|
|
266
|
-
JXG.registerElement('mesh3d',
|
|
271
|
+
JXG.registerElement('mesh3d', JXG.createMesh3D);
|
|
267
272
|
|
|
268
273
|
});
|
package/src/3d/curve3d.js
CHANGED
|
@@ -28,70 +28,174 @@
|
|
|
28
28
|
*/
|
|
29
29
|
/*global JXG:true, define: true*/
|
|
30
30
|
|
|
31
|
-
define(['jxg', '
|
|
32
|
-
], function (JXG, Type, ThreeD) {
|
|
31
|
+
define(['jxg', 'base/constants', 'utils/type'], function (JXG, Const, Type) {
|
|
33
32
|
"use strict";
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Constructor for 3D curves.
|
|
36
|
+
* @class Creates a new 3D curve object. Do not use this constructor to create a 3D curve. Use {@link JXG.Board#create} with type {@link Curve3D} instead.
|
|
37
|
+
*
|
|
38
|
+
* @augments JXG.GeometryElement3D
|
|
39
|
+
* @augments JXG.GeometryElement
|
|
40
|
+
* @param {View3D} view
|
|
41
|
+
* @param {Function} F
|
|
42
|
+
* @param {Function} X
|
|
43
|
+
* @param {Function} Y
|
|
44
|
+
* @param {Function} Z
|
|
45
|
+
* @param {Array} range
|
|
46
|
+
* @param {Object} attributes
|
|
47
|
+
* @see JXG.Board#generateName
|
|
48
|
+
*/
|
|
49
|
+
JXG.Curve3D = function (view, F, X, Y, Z, range, attributes) {
|
|
50
|
+
this.constructor(view.board, attributes, Const.OBJECT_TYPE_CURVE3D, Const.OBJECT_CLASS_3D);
|
|
51
|
+
this.constructor3D(view, 'surface3d');
|
|
52
|
+
|
|
53
|
+
this.id = this.view.board.setId(this, 'S3D');
|
|
54
|
+
this.board.finalizeAdding(this);
|
|
55
|
+
|
|
56
|
+
this.F = F;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Function which maps u to x; i.e. it defines the x-coordinate of the curve
|
|
60
|
+
* @function
|
|
61
|
+
* @returns Number
|
|
62
|
+
*/
|
|
63
|
+
this.X = X;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Function which maps u to y; i.e. it defines the y-coordinate of the curve
|
|
67
|
+
* @function
|
|
68
|
+
* @returns Number
|
|
69
|
+
*/
|
|
70
|
+
this.Y = Y;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Function which maps u to z; i.e. it defines the x-coordinate of the curve
|
|
74
|
+
* @function
|
|
75
|
+
* @returns Number
|
|
76
|
+
*/
|
|
77
|
+
this.Z = Z;
|
|
78
|
+
|
|
79
|
+
if (this.F !== null) {
|
|
80
|
+
this.X = function(u) { return this.F(u)[0]; };
|
|
81
|
+
this.Y = function(u) { return this.F(u)[1]; };
|
|
82
|
+
this.Z = function(u) { return this.F(u)[2]; };
|
|
83
|
+
}
|
|
38
84
|
|
|
39
|
-
|
|
40
|
-
elType: 'curve3D',
|
|
41
|
-
X: parents[1],
|
|
42
|
-
Y: parents[2],
|
|
43
|
-
Z: parents[3],
|
|
44
|
-
};
|
|
45
|
-
D3.F = [D3.X, D3.Y, D3.Z];
|
|
85
|
+
this.range = range;
|
|
46
86
|
|
|
47
|
-
|
|
48
|
-
|
|
87
|
+
this.methodMap = Type.deepCopy(this.methodMap, {
|
|
88
|
+
// TODO
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
JXG.Curve3D.prototype = new JXG.GeometryElement();
|
|
92
|
+
Type.copyPrototypeMethods(JXG.Curve3D, JXG.GeometryElement3D, 'constructor3D');
|
|
93
|
+
|
|
94
|
+
JXG.extend(JXG.Curve3D.prototype, /** @lends JXG.Curve3D.prototype */ {
|
|
95
|
+
|
|
96
|
+
updateDataArray: function () {
|
|
97
|
+
var steps = Type.evaluate(this.visProp.numberpointshigh),
|
|
98
|
+
r, s, e, delta,
|
|
99
|
+
c2d, u,
|
|
100
|
+
dataX, dataY,
|
|
101
|
+
p = [0, 0, 0];
|
|
102
|
+
|
|
103
|
+
dataX = [];
|
|
104
|
+
dataY = [];
|
|
105
|
+
|
|
106
|
+
if (Type.isArray(this.X)) {
|
|
107
|
+
steps = this.X.length;
|
|
108
|
+
for (u = 0; u < steps; u++) {
|
|
109
|
+
p = [this.X[u], this.Y[u], this.Z[u]];
|
|
110
|
+
c2d = this.view.project3DTo2D(p);
|
|
111
|
+
dataX.push(c2d[1]);
|
|
112
|
+
dataY.push(c2d[2]);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
r = Type.evaluate(this.range);
|
|
116
|
+
s = r[0];
|
|
117
|
+
e = r[1];
|
|
118
|
+
delta = (e - s) / (steps - 1);
|
|
119
|
+
for (u = s; u <= e; u += delta) {
|
|
120
|
+
if (this.F !== null){
|
|
121
|
+
p = this.F(u);
|
|
122
|
+
} else {
|
|
123
|
+
p = [this.X(u), this.Y(u), this.Z(u)];
|
|
124
|
+
}
|
|
125
|
+
c2d = this.view.project3DTo2D(p);
|
|
126
|
+
dataX.push(c2d[1]);
|
|
127
|
+
dataY.push(c2d[2]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {'X': dataX, 'Y': dataY};
|
|
131
|
+
},
|
|
49
132
|
|
|
50
|
-
|
|
51
|
-
// 3D curve given as t -> [X(t), Y(t), Z(t)]
|
|
133
|
+
update: function () { return this; },
|
|
52
134
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
135
|
+
updateRenderer: function () {
|
|
136
|
+
this.needsUpdate = false;
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @class This element creates a 3D parametric curves.
|
|
143
|
+
* @pseudo
|
|
144
|
+
* @description A 3D parametric curve is defined by a function
|
|
145
|
+
* <i>F: R<sup>1</sup> → R<sup>3</sup></i>.
|
|
146
|
+
*
|
|
147
|
+
* @name Curve3D
|
|
148
|
+
* @augments Curve
|
|
149
|
+
* @constructor
|
|
150
|
+
* @type Object
|
|
151
|
+
* @throws {Exception} If the element cannot be constructed with the given parent objects an exception is thrown.
|
|
152
|
+
* @param {Function_Function_Function_Array,Function} F<sub>X</sub>,F<sub>Y</sub>,F<sub>Z</sub>,range
|
|
153
|
+
* F<sub>X</sub>(u), F<sub>Y</sub>(u), F<sub>Z</sub>(u) are functions returning a number, range is the array containing
|
|
154
|
+
* lower and upper bound for the range of the parameter u. range may also be a function returning an array of length two.
|
|
155
|
+
* @param {Function_Array,Function} F,range Alternatively: F<sub>[X,Y,Z]</sub>(u) a function returning an array [x,y,z] of
|
|
156
|
+
* numbers, range as above.
|
|
157
|
+
* @param {Array_Array_Array} X,Y,Z Three arrays containing the coordinate points which define the curve.
|
|
158
|
+
*/
|
|
159
|
+
JXG.createCurve3D = function (board, parents, attributes) {
|
|
160
|
+
var view = parents[0],
|
|
161
|
+
F, X, Y, Z, range,
|
|
162
|
+
attr, el;
|
|
163
|
+
|
|
164
|
+
if (parents.length === 3) {
|
|
165
|
+
F = parents[1];
|
|
166
|
+
range = parents[2];
|
|
167
|
+
X = null;
|
|
168
|
+
Y = null;
|
|
169
|
+
Z = null;
|
|
170
|
+
} else {
|
|
171
|
+
X = parents[1];
|
|
172
|
+
Y = parents[2];
|
|
173
|
+
Z = parents[3];
|
|
174
|
+
range = parents[4];
|
|
175
|
+
F = null;
|
|
176
|
+
}
|
|
177
|
+
// TODO Throw error
|
|
61
178
|
|
|
62
|
-
|
|
63
|
-
|
|
179
|
+
attr = Type.copyAttributes(attributes, board.options, 'curve3d');
|
|
180
|
+
el = new JXG.Curve3D(view, F, X, Y, Z, range, attr);
|
|
64
181
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
el.
|
|
78
|
-
var i,
|
|
79
|
-
le = this.D3.X.length,
|
|
80
|
-
c2d;
|
|
81
|
-
|
|
82
|
-
this.dataX = [];
|
|
83
|
-
this.dataY = [];
|
|
84
|
-
|
|
85
|
-
for (i = 0; i < le; i++) {
|
|
86
|
-
c2d = view.project3DTo2D([this.D3.X[i], this.D3.Y[i], this.D3.Z[i]]);
|
|
87
|
-
this.dataX.push(c2d[1]);
|
|
88
|
-
this.dataY.push(c2d[2]);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
182
|
+
el.element2D = board.create('curve', [[], []], attr);
|
|
183
|
+
el.element2D.updateDataArray = function() {
|
|
184
|
+
var ret = el.updateDataArray();
|
|
185
|
+
this.dataX = ret.X;
|
|
186
|
+
this.dataY = ret.Y;
|
|
187
|
+
};
|
|
188
|
+
el.addChild(el.element2D);
|
|
189
|
+
el.inherits.push(el.element2D);
|
|
190
|
+
el.element2D.setParents(el);
|
|
191
|
+
|
|
192
|
+
el.element2D.prepareUpdate().update();
|
|
193
|
+
if (!board.isSuspendedUpdate) {
|
|
194
|
+
el.element2D.updateVisibility().updateRenderer();
|
|
91
195
|
}
|
|
92
196
|
|
|
93
197
|
return el;
|
|
94
198
|
};
|
|
95
|
-
JXG.registerElement('curve3d',
|
|
199
|
+
JXG.registerElement('curve3d', JXG.createCurve3D);
|
|
96
200
|
|
|
97
201
|
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2008-2022
|
|
3
|
+
Matthias Ehmann,
|
|
4
|
+
Carsten Miller,
|
|
5
|
+
Andreas Walter,
|
|
6
|
+
Alfred Wassermann
|
|
7
|
+
|
|
8
|
+
This file is part of JSXGraph.
|
|
9
|
+
|
|
10
|
+
JSXGraph is free software dual licensed under the GNU LGPL or MIT License.
|
|
11
|
+
|
|
12
|
+
You can redistribute it and/or modify it under the terms of the
|
|
13
|
+
|
|
14
|
+
* GNU Lesser General Public License as published by
|
|
15
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
16
|
+
(at your option) any later version
|
|
17
|
+
OR
|
|
18
|
+
* MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT
|
|
19
|
+
|
|
20
|
+
JSXGraph is distributed in the hope that it will be useful,
|
|
21
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23
|
+
GNU Lesser General Public License for more details.
|
|
24
|
+
|
|
25
|
+
You should have received a copy of the GNU Lesser General Public License and
|
|
26
|
+
the MIT License along with JSXGraph. If not, see <http://www.gnu.org/licenses/>
|
|
27
|
+
and <http://opensource.org/licenses/MIT/>.
|
|
28
|
+
*/
|
|
29
|
+
/*global JXG:true, define: true*/
|
|
30
|
+
|
|
31
|
+
define(['jxg'], function (JXG) {
|
|
32
|
+
"use strict";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Constructs a new GeometryElement3D object.
|
|
36
|
+
* @class This is the basic class for 3D geometry elements like Point3D and Line3D.
|
|
37
|
+
* @constructor
|
|
38
|
+
* @param {string} elType
|
|
39
|
+
* @borrows JXG.EventEmitter#on as this.on
|
|
40
|
+
* @borrows JXG.EventEmitter#off as this.off
|
|
41
|
+
* @borrows JXG.EventEmitter#triggerEventHandlers as this.triggerEventHandlers
|
|
42
|
+
* @borrows JXG.EventEmitter#eventHandlers as this.eventHandlers
|
|
43
|
+
*/
|
|
44
|
+
JXG.GeometryElement3D = function (view, elType) {
|
|
45
|
+
this.elType = elType;
|
|
46
|
+
this.id = this.board.setId(this, elType);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Pointer to the view3D in which the elemtn is constructed
|
|
50
|
+
* @type JXG.View3D
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
this.view = view;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Link to the 2D element(s) used to visualize the 3D element
|
|
57
|
+
* in a view. In case, there are several 2D elements, it is an array.
|
|
58
|
+
*
|
|
59
|
+
* @type JXG.GeometryElement,Array
|
|
60
|
+
* @private
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* p.element2D;
|
|
64
|
+
*/
|
|
65
|
+
this.element2D = null;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* If this property exists (and is true) the element is a 3D element.
|
|
69
|
+
*
|
|
70
|
+
* @type Boolean
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
this.is3D = true;
|
|
74
|
+
this.view.objects[this.id] = this;
|
|
75
|
+
this.view.objectsList.push(this);
|
|
76
|
+
|
|
77
|
+
if (this.name !== '') {
|
|
78
|
+
this.view.elementsByName[this.name] = this;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return JXG.GeometryElement3D;
|
|
84
|
+
});
|