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.
Files changed (56) hide show
  1. package/README.md +24 -0
  2. package/build/Readme.md +17 -0
  3. package/build/bin/jsxcompressor.js +1 -0
  4. package/build/bin/jsxgraphcore-min.js +7 -0
  5. package/build/bin/jsxgraphcore.js +83017 -0
  6. package/build/bin/jsxgraphcore.min.js +67 -0
  7. package/build/compressor.build.json +14 -0
  8. package/build/compressor.deps.js +8 -0
  9. package/build/core-amd.build.json +14 -0
  10. package/build/core-amd.deps.js +81 -0
  11. package/build/core.build.json +14 -0
  12. package/build/core.deps.js +102 -0
  13. package/build/plot.build.json +15 -0
  14. package/distrib/README.md +24 -0
  15. package/distrib/geogebra.min.js +1 -1
  16. package/distrib/geonext.min.js +1 -1
  17. package/distrib/index.d.ts +28 -7
  18. package/distrib/intergeo.min.js +1 -1
  19. package/distrib/jsxgraph.css +6 -0
  20. package/distrib/jsxgraphcore.js +3 -3
  21. package/distrib/jsxgraphsrc.js +3558 -1857
  22. package/distrib/sketch.min.js +1 -1
  23. package/package.json +1 -1
  24. package/src/3d/box3d.js +43 -38
  25. package/src/3d/curve3d.js +157 -53
  26. package/src/3d/element3d.js +84 -0
  27. package/src/3d/linspace3d.js +427 -146
  28. package/src/3d/point3d.js +360 -123
  29. package/src/3d/surface3d.js +140 -42
  30. package/src/3d/view3d.js +319 -164
  31. package/src/base/board.js +163 -78
  32. package/src/base/constants.js +8 -1
  33. package/src/base/curve.js +51 -9
  34. package/src/base/polygon.js +111 -69
  35. package/src/base/text.js +122 -19
  36. package/src/base/ticks.js +12 -3
  37. package/src/element/button.js +7 -3
  38. package/src/element/checkbox.js +8 -4
  39. package/src/element/composition.js +7 -1
  40. package/src/element/conic.js +2 -2
  41. package/src/element/input.js +9 -5
  42. package/src/jsxgraph.js +4 -1
  43. package/src/loadjsxgraph.js +13 -8
  44. package/src/math/clip.js +34 -134
  45. package/src/math/geometry.js +204 -3
  46. package/src/math/math.js +1 -2
  47. package/src/math/nlp.js +865 -774
  48. package/src/options.js +185 -12
  49. package/src/options3d.js +24 -7
  50. package/src/parser/jessiecode.js +9 -3
  51. package/src/renderer/abstract.js +26 -15
  52. package/src/renderer/canvas.js +2 -2
  53. package/src/renderer/svg.js +15 -2
  54. package/src/utils/env.js +36 -53
  55. package/src/utils/type.js +75 -2
  56. package/src/3d/threed.js +0 -38
@@ -32,10 +32,125 @@
32
32
  * Create linear spaces of dimension at least one,
33
33
  * i.e. lines and planes.
34
34
  */
35
- define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
36
- ], function (JXG, Type, Mat, Geometry, ThreeD) {
35
+ define(['jxg', 'base/constants', 'utils/type', 'math/math', 'math/geometry'
36
+ ], function (JXG, Const, Type, Mat, Geometry) {
37
37
  "use strict";
38
38
 
39
+ // -----------------------
40
+ // Lines
41
+ // -----------------------
42
+
43
+ /**
44
+ * Constructor for 3D lines.
45
+ * @class Creates a new 3D line object. Do not use this constructor to create a 3D line. Use {@link JXG.Board#create} with type {@link Line3D} instead.
46
+ *
47
+ * @augments JXG.GeometryElement3D
48
+ * @augments JXG.GeometryElement
49
+ * @param {View3D} view
50
+ * @param {Point3D|Array} point
51
+ * @param {Array} direction
52
+ * @param {Array} range
53
+ * @param {Object} attributes
54
+ * @see JXG.Board#generateName
55
+ */
56
+ JXG.Line3D = function (view, point, direction, range, attributes) {
57
+ this.constructor(view.board, attributes, Const.OBJECT_TYPE_LINE3D, Const.OBJECT_CLASS_3D);
58
+ this.constructor3D(view, 'line3d');
59
+
60
+ this.id = this.view.board.setId(this, 'L3D');
61
+ this.board.finalizeAdding(this);
62
+
63
+ /**
64
+ * 3D point which - together with a direction - defines the line.
65
+ * @type JXG.Point3D
66
+ *
67
+ * @see JXG.Line3D#direction
68
+ */
69
+ this.point = point;
70
+
71
+ /**
72
+ * Direction which - together with a point - defines the line. Array of numbers or functions (of length 3) or function
73
+ * returning array of length 3.
74
+ *
75
+ * @type Array,Function
76
+ * @see JXG.Line3D#point
77
+ */
78
+ this.direction = direction;
79
+
80
+ /**
81
+ * Range [r1, r2] of the line. r1, r2 can be numbers or functions.
82
+ * The 3D line goes from (point + r1 * direction) to (point + r2 * direction)
83
+ * @type Array
84
+ */
85
+ this.range = range || [-Infinity, Infinity];
86
+
87
+ /**
88
+ * Starting point of the 3D line
89
+ * @type JXG.Point3D
90
+ * @private
91
+ */
92
+ this.point1 = null;
93
+
94
+ /**
95
+ * End point of the 3D line
96
+ * @type JXG.Point3D
97
+ * @private
98
+ */
99
+ this.point2 = null;
100
+
101
+ this.methodMap = Type.deepCopy(this.methodMap, {
102
+ // TODO
103
+ });
104
+ };
105
+ JXG.Line3D.prototype = new JXG.GeometryElement();
106
+ Type.copyPrototypeMethods(JXG.Line3D, JXG.GeometryElement3D, 'constructor3D');
107
+
108
+ JXG.extend(JXG.Line3D.prototype, /** @lends JXG.Line3D.prototype */ {
109
+
110
+ /**
111
+ * Determine one end point of a 3D line from point, direction and range.
112
+ *
113
+ * @param {Number|function} r
114
+ * @private
115
+ * @returns Array
116
+ */
117
+ getPointCoords: function (r) {
118
+ var p = [],
119
+ d = [],
120
+ i, r0;
121
+
122
+ p = [this.point.X(), this.point.Y(), this.point.Z()];
123
+
124
+ if (Type.isFunction(this.direction)) {
125
+ d = this.direction();
126
+ } else {
127
+ for (i = 1; i < 4; i++) {
128
+ d.push(Type.evaluate(this.direction[i]));
129
+ }
130
+ }
131
+
132
+ r0 = Type.evaluate(r);
133
+ // TODO: test also in the finite case
134
+ if (Math.abs(r0) === Infinity) {
135
+ r = this.view.intersectionLineCube(p, d, r0);
136
+ }
137
+
138
+ return [
139
+ p[0] + d[0] * r0,
140
+ p[1] + d[1] * r0,
141
+ p[2] + d[2] * r0
142
+ ];
143
+ },
144
+
145
+ update: function () { return this; },
146
+
147
+ updateRenderer: function () {
148
+ this.needsUpdate = false;
149
+ return this;
150
+ }
151
+
152
+ });
153
+
39
154
  /**
40
155
  * @class This element is used to provide a constructor for a 3D line.
41
156
  * @pseudo
@@ -51,168 +166,288 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
51
166
  * All numbers can also be provided as functions returning a number.
52
167
  *
53
168
  * @name Line3D
54
- * @augments JXG.Curve
169
+ * @augments JXG.GeometryElement3D
55
170
  * @constructor
56
- * @type JXG.Curve
171
+ * @type JXG.Line3D
57
172
  * @throws {Exception} If the element cannot be constructed with the given parent
58
173
  * objects an exception is thrown.
59
- * @param {JXG.Point_number,JXG.Point,JXG.Line,JXG.Circle} center,radius The center must be given as a {@link JXG.Point}, see {@link JXG.providePoints}, but the radius can be given
60
- * as a number (which will create a circle with a fixed radius), another {@link JXG.Point}, a {@link JXG.Line} (the distance of start and end point of the
61
- * line will determine the radius), or another {@link JXG.Circle}.
174
+ * @param {JXG.Point3D,array_JXG.Point3D,array} point1,point2 First and second defining point.
175
+ * @param {JXG.Point3D,array_array,function_array,function} point,direction,range Alternatively, point, direction and range can be supplied.
176
+ * <ul>
177
+ * <li> point: Point3D or array of length 3
178
+ * <li> direction: array of length 3 or function returning an array of numbers or function returning an array
179
+ * <li> range: array of length 2, elements can also be functions.
180
+ * </ul>
181
+ *
182
+ * @example
183
+ * var bound = [-5, 5];
184
+ * var view = board.create('view3d',
185
+ * [[-6, -3], [8, 8],
186
+ * [bound, bound, bound]],
187
+ * {});
188
+ * var p = view.create('point3d', [1, 2, 2], { name:'A', size: 5 });
189
+ * // Lines through 2 points
190
+ * var l1 = view.create('line3d', [[1, 3, 3], [-3, -3, -3]], {point1: {visible: true}, point2: {visible: true} });
191
+ * var l2 = view.create('line3d', [p, l1.point1]);
192
+ *
193
+ * // Line by point, direction, range
194
+ * var l3 = view.create('line3d', [p, [0, 0, 1], [-2, 4]]);
195
+ *
196
+ * </pre><div id="JXG05f9baa4-6059-4502-8911-6a934f823b3d" class="jxgbox" style="width: 300px; height: 300px;"></div>
197
+ * <script type="text/javascript">
198
+ * (function() {
199
+ * var board = JXG.JSXGraph.initBoard('JXG05f9baa4-6059-4502-8911-6a934f823b3d',
200
+ * {boundingbox: [-8, 8, 8,-8], axis: false, showcopyright: false, shownavigation: false});
201
+ * var bound = [-5, 5];
202
+ * var view = board.create('view3d',
203
+ * [[-6, -3], [8, 8],
204
+ * [bound, bound, bound]],
205
+ * {});
206
+ * var p = view.create('point3d', [1, 2, 2], { name:'A', size: 5 });
207
+ * // Lines through 2 points
208
+ * var l1 = view.create('line3d', [[1, 3, 3], [-3, -3, -3]], {name: 'll1', point1: {visible: true}, point2: {visible: true} });
209
+ * var l2 = view.create('line3d', [p, l1.point1]);
210
+ * // Line by point, direction, range
211
+ * var l3 = view.create('line3d', [p, [0, 0, 1], [-2, 4]]);
212
+ * })();
213
+ *
214
+ * </script><pre>
62
215
  *
63
216
  */
64
- ThreeD.createLine = function (board, parents, attributes) {
217
+ JXG.createLine3D = function (board, parents, attributes) {
65
218
  var view = parents[0],
66
- attr, D3, point, point1, point2,
219
+ attr, points,
220
+ point, direction, range,
221
+ point1, point2,
67
222
  el;
68
223
 
69
- // Range
70
- D3 = {
71
- elType: 'line3d',
72
- range: parents[3] || [-Infinity, Infinity]
73
- };
224
+ attr = Type.copyAttributes(attributes, board.options, 'line3d');
74
225
 
75
- // Point
76
- if (Type.isPoint(parents[1])) {
77
- point = parents[1];
78
- } else {
79
- point = view.create('point3d', parents[1], { visible: false, name: '', withLabel: false });
80
- }
81
- D3.point = point;
226
+ // In any case, parents[1] contains a point or point coordinates
227
+ point = Type.providePoints3D(view, [parents[1]], attributes, 'line3d', ['point'])[0];
82
228
 
83
- // Direction
84
- if (Type.isPoint(parents[2]) && Type.exists(parents[2].D3)) {
229
+ if (Type.isPoint3D(parents[2]) || (Type.isArray(parents[2]) && parents.length === 3)) {
85
230
  // Line defined by two points
86
231
 
87
232
  point1 = point;
88
- point2 = parents[2];
89
- D3.direction = function () {
233
+ point2 = Type.providePoints3D(view, [parents[2]], attributes, 'line3d', ['point2'])[0];
234
+ direction = function () {
90
235
  return [
91
- point2.D3.X() - point.D3.X(),
92
- point2.D3.Y() - point.D3.Y(),
93
- point2.D3.Z() - point.D3.Z()
236
+ point2.X() - point.X(),
237
+ point2.Y() - point.Y(),
238
+ point2.Z() - point.Z()
94
239
  ];
95
240
  };
96
- D3.range = [0, 1];
241
+ range = [0, 1];
242
+ el = new JXG.Line3D(view, point, direction, range, attr);
97
243
  } else {
98
244
  // Line defined by point, direction and range
99
245
 
100
246
  // Directions are handled as arrays of length 4,
101
247
  // i.e. with homogeneous coordinates.
102
248
  if (Type.isFunction(parents[2])) {
103
- D3.direction = parents[2];
249
+ direction = parents[2];
104
250
  } else if (parents[2].length === 3) {
105
- D3.direction = [1].concat(parents[2]);
251
+ direction = [1].concat(parents[2]);
106
252
  } else if (parents[2].length === 4) {
107
- D3.direction = parents[2];
253
+ direction = parents[2];
108
254
  } else {
109
- // Throw error
255
+ // TODO Throw error
110
256
  }
257
+ range = parents[3];
111
258
 
112
- // Direction given as array
113
- D3.getPointCoords = function (r) {
114
- var p = [],
115
- d = [],
116
- i;
117
-
118
- p.push(point.D3.X());
119
- p.push(point.D3.Y());
120
- p.push(point.D3.Z());
121
-
122
- if (Type.isFunction(D3.direction)) {
123
- d = D3.direction();
124
- } else {
125
- for (i = 1; i < 4; i++) {
126
- d.push(Type.evaluate(D3.direction[i]));
127
- }
128
- }
129
- if (Math.abs(r) === Infinity) {
130
- r = view.intersectionLineCube(p, d, r);
131
- }
132
- return [
133
- p[0] + d[0] * r,
134
- p[1] + d[1] * r,
135
- p[2] + d[2] * r
136
- ];
259
+ points = Type.providePoints3D(view, [[0, 0, 0], [0, 0, 0]], attributes, 'line3d', ['point1', 'point2']);
260
+
261
+ // Create a line3d with two dummy points
262
+ el = new JXG.Line3D(view, point, direction, range, attr);
137
263
 
264
+ // Now set the real points which define the line
265
+ points[0].F = function () {
266
+ return el.getPointCoords(Type.evaluate(el.range[0]));
138
267
  };
268
+ points[0].prepareUpdate().update();
269
+ point1 = points[0];
139
270
 
140
- attr = Type.copyAttributes(attributes, board.options, 'line3d', 'point1');
141
- point1 = view.create('point3d', [
142
- function () {
143
- return D3.getPointCoords(Type.evaluate(D3.range[0]));
144
- }
145
- ], attr);
146
- attr = Type.copyAttributes(attributes, board.options, 'line3d', 'point2');
147
- point2 = view.create('point3d', [
148
- function () {
149
- return D3.getPointCoords(Type.evaluate(D3.range[1]));
150
- }
151
- ], attr);
271
+ points[1].F = function () {
272
+ return el.getPointCoords(Type.evaluate(el.range[1]));
273
+ };
274
+ points[1].prepareUpdate().update();
275
+ point2 = points[1];
152
276
  }
277
+ // TODO Throw error
278
+
279
+ el.element2D = view.create('segment', [point1.element2D, point2.element2D], attr);
280
+ el.addChild(el.element2D);
281
+ el.inherits.push(el.element2D);
282
+ el.element2D.setParents(el);
153
283
 
154
- attr = Type.copyAttributes(attributes, board.options, 'line3d');
155
- el = view.create('segment', [point1, point2], attr);
156
- el.point1 = point1;
157
- el.point2 = point2;
158
284
  point1.addChild(el);
159
285
  point2.addChild(el);
160
- el.D3 = D3;
286
+ el.point1 = point1;
287
+ el.point2 = point2;
161
288
 
289
+ el.update();
290
+ el.element2D.prepareUpdate().update().updateRenderer();
162
291
  return el;
163
292
  };
164
- JXG.registerElement('line3d', ThreeD.createLine);
293
+ JXG.registerElement('line3d', JXG.createLine3D);
165
294
 
166
- ThreeD.createPlane = function (board, parents, attributes) {
167
- var view = parents[0],
168
- attr, D3,
169
- point,
170
- vec1 = parents[2],
171
- vec2 = parents[3],
172
- el, grid, update;
173
-
174
- // D3: {
175
- // point,
176
- // vec1,
177
- // vec2,
178
- // poin1,
179
- // point2,
180
- // normal array of len 3
181
- // d
182
- // }
183
- D3 = {
184
- elType: 'plane3d',
185
- dir1: [],
186
- dir2: [],
187
- range1: parents[4],
188
- range2: parents[5],
189
- vec1: vec1,
190
- vec2: vec2
191
- };
295
+ // -----------------------
296
+ // Planes
297
+ // -----------------------
192
298
 
193
- if (Type.isPoint(parents[1])) {
194
- point = parents[1];
195
- } else {
196
- point = view.create('point3d', parents[1], { visible: false, name: '', withLabel: false });
197
- }
198
- D3.point = point;
199
-
200
- D3.updateNormal = function () {
201
- var i;
299
+ /**
300
+ * Constructor for 3D planes.
301
+ * @class Creates a new 3D plane object. Do not use this constructor to create a 3D plane. Use {@link JXG.Board#create} with type {@link Plane3D} instead.
302
+ *
303
+ * @augments JXG.GeometryElement3D
304
+ * @augments JXG.GeometryElement
305
+ * @param {View3D} view
306
+ * @param {Point3D,Array} point
307
+ * @param {Array} direction1
308
+ * @param {Array} range1
309
+ * @param {Array} direction2
310
+ * @param {Array} range2
311
+ * @param {Object} attributes
312
+ * @see JXG.Board#generateName
313
+ */
314
+ JXG.Plane3D = function (view, point, dir1, range1, dir2, range2, attributes) {
315
+ this.constructor(view.board, attributes, Const.OBJECT_TYPE_PLANE3D, Const.OBJECT_CLASS_3D);
316
+ this.constructor3D(view, 'plane3d');
317
+
318
+ this.id = this.view.board.setId(this, 'PL3D');
319
+ this.board.finalizeAdding(this);
320
+
321
+ /**
322
+ * 3D point which - together with two direction vectors - defines the plane.
323
+ *
324
+ * @type JXG.Point3D
325
+ *
326
+ * @see JXG.3D#direction1
327
+ * @see JXG.3D#direction2
328
+ */
329
+ this.point = point;
330
+
331
+ /**
332
+ * Two linearly independent vectors - together with a point - define the plane. Each of these direction vectors is an
333
+ * array of numbers or functions (of length 3) or function returning array of length 3.
334
+ *
335
+ * @type Array,Function
336
+ *
337
+ * @see JXG.Plane3D#point
338
+ * @see JXG.Plane3D#direction2
339
+ */
340
+ this.direction1 = dir1;
341
+
342
+ /**
343
+ * Two linearly independent vectors - together with a point - define the plane. Each of these direction vectors is an
344
+ * array of numbers or functions (of length 3) or function returning array of length 3.
345
+ *
346
+ * @type Array,Function
347
+ * @see JXG.Plane3D#point
348
+ * @see JXG.Plane3D#direction1
349
+ */
350
+ this.direction2 = dir2;
351
+
352
+ /**
353
+ * Range [r1, r2] of {@link direction1}. The 3D line goes from (point + r1 * direction1) to (point + r2 * direction1)
354
+ * @type {Array}
355
+ */
356
+ this.range1 = range1 || [-Infinity, Infinity];
357
+
358
+ /**
359
+ * Range [r1, r2] of {@link direction2}. The 3D line goes from (point + r1 * direction2) to (point + r2 * direction2)
360
+ * @type {Array}
361
+ */
362
+ this.range2 = range2 || [-Infinity, Infinity];
363
+
364
+ /**
365
+ * Direction vector 1 of the 3D plane. Contains the evaluated coordinates from {@link direction1} and {@link range1}.
366
+ * @type Array
367
+ * @private
368
+ *
369
+ * @see updateNormal
370
+ */
371
+ this.vec1 = [0, 0, 0];
372
+
373
+ /**
374
+ * Direction vector 2 of the 3D plane. Contains the evaluated coordinates from {@link direction2} and {@link range2}.
375
+ *
376
+ * @type Array
377
+ * @private
378
+ *
379
+ * @see updateNormal
380
+ */
381
+ this.vec2 = [0, 0, 0];
382
+
383
+ this.grid = null;
384
+
385
+ /**
386
+ * Normal vector of the plane. Left hand side of the Hesse normal form.
387
+
388
+ * @type Array
389
+ * @private
390
+ *
391
+ * @see updateNormal
392
+ *
393
+ */
394
+ this.normal = [0, 0, 0];
395
+
396
+ /**
397
+ * Right hand side of the Hesse normal form.
398
+
399
+ * @type Array
400
+ * @private
401
+ *
402
+ * @see updateNormal
403
+ *
404
+ */
405
+ this.d = 0;
406
+
407
+ this.updateNormal();
408
+
409
+ this.methodMap = Type.deepCopy(this.methodMap, {
410
+ // TODO
411
+ });
412
+ };
413
+ JXG.Plane3D.prototype = new JXG.GeometryElement();
414
+ Type.copyPrototypeMethods(JXG.Plane3D, JXG.GeometryElement3D, 'constructor3D');
415
+
416
+ JXG.extend(JXG.Plane3D.prototype, /** @lends JXG.Plane3D.prototype */ {
417
+
418
+ /**
419
+ * Update the Hesse normal form of the plane, i.e. update normal vector and right hand side.
420
+ * Updates also {@link vec1} and {@link vec2}.
421
+ *
422
+ * @name updateNormal
423
+ * @function
424
+ * @returns {Object} Reference to the Plane3D object
425
+ * @private
426
+ * @example
427
+ * plane.updateNormal();
428
+ *
429
+ */
430
+ updateNormal: function () {
431
+ var i, len;
202
432
  for (i = 0; i < 3; i++) {
203
- D3.dir1[i] = Type.evaluate(D3.vec1[i]);
204
- D3.dir2[i] = Type.evaluate(D3.vec2[i]);
433
+ this.vec1[i] = Type.evaluate(this.direction1[i]);
434
+ this.vec2[i] = Type.evaluate(this.direction2[i]);
205
435
  }
206
- D3.normal = Mat.crossProduct(D3.dir1, D3.dir2);
207
- D3.d = Mat.innerProduct(D3.point.D3.coords.slice(1), D3.normal, 3);
208
- };
209
- D3.updateNormal();
210
436
 
211
- attr = Type.copyAttributes(attributes, board.options, 'plane3d');
212
- el = board.create('curve', [[], []], attr);
213
- el.D3 = D3;
437
+ this.normal = Mat.crossProduct(this.vec1, this.vec2);
438
+
439
+ len = Mat.norm(this.normal);
440
+ if (Math.abs(len) > Mat.eps) {
441
+ for (i = 0; i < 3; i++) {
442
+ this.normal[i] /= len;
443
+ }
444
+ }
445
+ this.d = Mat.innerProduct(this.point.coords.slice(1), this.normal, 3);
214
446
 
215
- el.updateDataArray = function () {
447
+ return this;
448
+ },
449
+
450
+ updateDataArray: function () {
216
451
  var s1, e1, s2, e2,
217
452
  c2d, l1, l2,
218
453
  planes = ['xPlaneRear', 'yPlaneRear', 'zPlaneRear'],
@@ -220,17 +455,19 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
220
455
  v1 = [0, 0, 0],
221
456
  v2 = [0, 0, 0],
222
457
  q = [0, 0, 0],
223
- p = [0, 0, 0], d, i, j, a, b, first, pos, pos_akt;
458
+ p = [0, 0, 0], d, i, j, a, b, first, pos, pos_akt,
459
+ view = this.view;
224
460
 
225
461
  this.dataX = [];
226
462
  this.dataY = [];
227
463
 
228
- this.D3.updateNormal();
464
+ this.updateNormal();
229
465
 
230
466
  // Infinite plane
231
- if (this.D3.elType !== 'axisplane3d' && view.defaultAxes &&
232
- (!D3.range1 || !D3.range2)
233
- ) {
467
+ if (this.elType !== 'axisplane3d' && view.defaultAxes &&
468
+ Type.evaluate(this.range1[0]) === -Infinity && Type.evaluate(this.range1[1]) === Infinity &&
469
+ Type.evaluate(this.range2[0]) === -Infinity && Type.evaluate(this.range2[1]) === Infinity
470
+ ) {
234
471
 
235
472
  // Start with the rear plane.
236
473
  // Determine the intersections with the view bbox3d
@@ -256,10 +493,10 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
256
493
 
257
494
  // Point on the front plane of the bbox3d
258
495
  p = [0, 0, 0];
259
- p[j] = view.D3.bbox3d[j][1];
496
+ p[j] = view.bbox3D[j][1];
260
497
 
261
498
  // d is the rhs of the Hesse normal form of the front plane.
262
- d = Mat.innerProduct(p, view.defaultAxes[planes[j]].D3.normal, 3);
499
+ d = Mat.innerProduct(p, view.defaultAxes[planes[j]].normal, 3);
263
500
  p = view.intersectionPlanePlane(this, view.defaultAxes[planes[j]], d);
264
501
 
265
502
  if (p[0].length === 3 && p[1].length === 3) {
@@ -310,21 +547,22 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
310
547
  break;
311
548
  }
312
549
  } while (pos !== first);
550
+
313
551
  c2d = view.project3DTo2D(points[first][0]);
314
552
  this.dataX.push(c2d[1]);
315
553
  this.dataY.push(c2d[2]);
316
554
 
317
555
  } else {
318
556
  // 3D bounded flat
319
- s1 = Type.evaluate(this.D3.range1[0]);
320
- e1 = Type.evaluate(this.D3.range1[1]);
321
- s2 = Type.evaluate(this.D3.range2[0]);
322
- e2 = Type.evaluate(this.D3.range2[1]);
557
+ s1 = Type.evaluate(this.range1[0]);
558
+ e1 = Type.evaluate(this.range1[1]);
559
+ s2 = Type.evaluate(this.range2[0]);
560
+ e2 = Type.evaluate(this.range2[1]);
323
561
 
324
- q = this.D3.point.D3.coords.slice(1);
562
+ q = this.point.coords.slice(1);
325
563
 
326
- v1 = this.D3.dir1.slice();
327
- v2 = this.D3.dir2.slice();
564
+ v1 = this.vec1.slice();
565
+ v2 = this.vec2.slice();
328
566
  l1 = Mat.norm(v1, 3);
329
567
  l2 = Mat.norm(v2, 3);
330
568
  for (i = 0; i < 3; i++) {
@@ -350,26 +588,69 @@ define(['jxg', 'utils/type', 'math/math', 'math/geometry', '3d/view3d'
350
588
  this.dataX.push(this.dataX[0]);
351
589
  this.dataY.push(this.dataY[0]);
352
590
  }
591
+ return { 'X': this.dataX, 'Y': this.dataY};
592
+ },
593
+
594
+ update: function () {
595
+ return this;
596
+ },
597
+
598
+ updateRenderer: function () {
599
+ this.needsUpdate = false;
600
+ return this;
601
+ }
602
+ });
603
+
604
+ JXG.createPlane3D = function (board, parents, attributes) {
605
+ var view = parents[0],
606
+ attr,
607
+ point,
608
+ dir1 = parents[2],
609
+ dir2 = parents[3],
610
+ range1 = parents[4] || [-Infinity, Infinity],
611
+ range2 = parents[5] || [-Infinity, Infinity],
612
+ el, grid;
613
+
614
+
615
+ point = Type.providePoints3D(view, [parents[1]], attributes, 'plane3d', ['point'])[0];
616
+ if (point === false) {
617
+ // TODO Throw error
618
+ }
619
+
620
+ attr = Type.copyAttributes(attributes, board.options, 'plane3d');
621
+ el = new JXG.Plane3D(view, point, dir1, range1, dir2, range2, attr);
622
+ point.addChild(el);
623
+
624
+
625
+ el.element2D = view.create('curve', [[], []], attr);
626
+ el.element2D.updateDataArray = function() {
627
+ var ret = el.updateDataArray();
628
+ this.dataX = ret.X;
629
+ this.dataY = ret.Y;
353
630
  };
631
+ el.addChild(el.element2D);
632
+ el.inherits.push(el.element2D);
633
+ el.element2D.setParents(el);
354
634
 
355
- attr = Type.copyAttributes(attributes.mesh3d, board.options, 'mesh3d');
356
635
 
357
- if (D3.range1 && D3.range2) {
358
- grid = view.create('mesh3d', [point.D3.coords.slice(1), vec1, D3.range1, vec2, D3.range2], attr);
636
+ attr = Type.copyAttributes(attributes.mesh3d, board.options, 'mesh3d');
637
+ if (Math.abs(el.range1[0]) !== Infinity && Math.abs(el.range1[1]) !== Infinity &&
638
+ Math.abs(el.range2[0]) !== Infinity && Math.abs(el.range2[1]) !== Infinity
639
+ ) {
640
+ grid = view.create('mesh3d', [ function() { return point.coords; }, dir1, range1, dir2, range2 ], attr);
359
641
  el.grid = grid;
642
+ el.addChild(grid);
360
643
  el.inherits.push(grid);
644
+ grid.setParents(el);
361
645
  }
362
646
 
363
- // update = el.update;
364
- // el.update = function () {
365
- // if (el.needsUpdate) {
366
- // update.apply(el);
367
- // }
368
- // return this;
369
- // };
647
+ el.element2D.prepareUpdate().update();
648
+ if (!board.isSuspendedUpdate) {
649
+ el.element2D.updateVisibility().updateRenderer();
650
+ }
370
651
 
371
652
  return el;
372
653
  };
373
- JXG.registerElement('plane3d', ThreeD.createPlane);
654
+ JXG.registerElement('plane3d', JXG.createPlane3D);
374
655
 
375
656
  });